home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume89 / graphics / julia.1 < prev    next >
Internet Message Format  |  1989-05-10  |  66KB

  1. Path: xanth!ames!oliveb!sun!swap!page
  2. From: page%swap@Sun.COM (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v89i122:  julia - draw julia set
  5. Message-ID: <104014@sun.Eng.Sun.COM>
  6. Date: 10 May 89 04:14:36 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 2224
  9. Approved: page@sun.com
  10.  
  11. Submitted-by: mott@ucscd.ucsc.edu (Hung H. Le)
  12. Posting-number: Volume 89, Issue 122
  13. Archive-name: graphics/julia.1
  14.  
  15. Enclosed is JuliaIIM, a program to draw the Julia Set (related to
  16. Mandelbrot set).  I also include "qmenu" (previously posted) for
  17. completeness since it is needed to compile JuliaIIM.
  18.  
  19. [uuencoded executable included.  ..bob]
  20.  
  21. # This is a shell archive.
  22. # Remove anything above and including the cut line.
  23. # Then run the rest of the file through 'sh'.
  24. # Unpacked files will be owned by you and have default permissions.
  25. #----cut here-----cut here-----cut here-----cut here----#
  26. #!/bin/sh
  27. # shar: SHell ARchive
  28. # Run the following text through 'sh' to create:
  29. #    JuliaIIM.c
  30. #    JuliaIIM.doc
  31. #    JuliaIIM.uu
  32. #    Makefile.qmenu
  33. #    Readme.qmenu
  34. #    mtst.c
  35. #    qmenu.c
  36. #    qmenu.h
  37. #    request.h
  38. # This is archive 1 of a 1-part kit.
  39. # This archive created: Tue May  9 21:08:00 1989
  40. echo "extracting JuliaIIM.c"
  41. sed 's/^X//' << \SHAR_EOF > JuliaIIM.c
  42. X/*
  43. X * JuliaIIM -- Quick a dirty way to look at the Julia Set
  44. X *
  45. X * April 27, 89 --
  46. X *    Clean up for public distribution.
  47. X *    Menus are generated using the "qmenu" package
  48. X *    Requester is genrated using "blk"
  49. X *         both packages are written by
  50. X *                Stuart Ferguson        1/89
  51. X *                (shf@well.UUCP)
  52. X *        and are availabe in the Public Domain.
  53. X *    The scaling of the pictures left much to be desired.
  54. X *  One thing I really would like to work on is the "Imanginary Map".
  55. X *    I would like to draw a Mandelbrot picture there and let the user
  56. X *     pick the value by clicking on the Mandelbrot map. This will give a
  57. X *    very nice illustration that the Mandelbrot picture is really a 
  58. X *    dictionary of the Julia Set.
  59. X *    I had planned to work on this some more but finals are coming up.
  60. X *
  61. X *    You may use this codes if they are useful to you.
  62. X *
  63. X * compiles using 3.4a Manx
  64. X * 1> cc JuliaIIM.c
  65. X * 1> ln JuliaIIM.o qmenu.o -lm -lc
  66. X */
  67. X#include "functions.h"
  68. X#include "exec/types.h"
  69. X#include "graphics/gfxmacros.h"
  70. X#include "intuition/intuition.h"
  71. X#include "math.h"
  72. X
  73. X#define INTUITION_REV 0L
  74. X#define GRAPHICS_REV 0L
  75. X/* Write out Text */
  76. X#define MyText(r,x,y,b) Move((r),(x), (y)); Text((r), (b), (long) strlen(b))
  77. X/* Clear Screen */
  78. X#define MyClear(r,x,y) SetAPen((r), 0L); RectFill((r), 0L, 0L, (x), (y))
  79. X
  80. X/* external for qmenu.o and request.h */
  81. Xstruct TextAttr ta = { (UBYTE*) "topaz.font", 8,0,0 };
  82. X
  83. X/* global variables */
  84. Xstruct IntuitionBase *IntuitionBase = 0L;
  85. Xstruct GfxBase *GfxBase = 0L;
  86. Xstruct Window *Window = 0L;
  87. Xstruct RastPort *RastPort = 0L;
  88. X
  89. Xstruct NewWindow nw =
  90. X{
  91. X    50, 10,            /* leftedge, topedge */
  92. X    340, 150,        /* width, height */
  93. X    -1, -1,            /* detail pen, block pen (default) */
  94. X    CLOSEWINDOW | MENUPICK | MOUSEBUTTONS | REQCLEAR | GADGETDOWN,    /* IDCMP Flag */
  95. X    SMART_REFRESH | WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | ACTIVATE | GIMMEZEROZERO | WINDOWSIZING,
  96. X    NULL, NULL,        /* first gadget, check mark */ 
  97. X    (UBYTE *) "Julia IIM Window",        /* title */
  98. X    NULL, NULL,        /* screen, bitmap */
  99. X    100, 50,        /* minwidth, minheight */
  100. X    640, 200,        /* maxwidth, maxheight */
  101. X    WBENCHSCREEN    /* type */
  102. X};
  103. X
  104. X#define PI 3.14159
  105. X#define HALF_PI 1.57079
  106. X#define X_RES 640.0
  107. X#define Y_RES 200.0
  108. X
  109. X/* global variables */
  110. XUBYTE Buf[20];
  111. Xdouble x, y, cx, cy;
  112. Xint offset_width, offset_height;
  113. Xint MaxDots;
  114. XSTATIC BOOL Stop, Show, Clear, Pixel_Mode;
  115. X
  116. X/* gadget */
  117. X#define CAN_ID  0x80 
  118. X#define OK_ID    0x81  
  119. X#define STR_ID  0x82 
  120. X#define NUMCHR 20
  121. XUBYTE undo[NUMCHR];
  122. X#define REQ mot_req
  123. X#define REQ_BUF mot_nbuf
  124. X#include "request.h"
  125. X/* gadget end */
  126. X
  127. X/* Menu Stuffs */
  128. X#include "qmenu.h"
  129. X
  130. X#define NILSUB    {NULL,NULL}
  131. X
  132. X/* STOP MENU */
  133. X#define STOP 0
  134. Xchar *ms_str[] = 
  135. X{
  136. X    "!=SStop Calculation",
  137. X    NULL 
  138. X};
  139. X
  140. Xstruct NewMenu ms_sub[] = 
  141. X{
  142. X    NILSUB,
  143. X};
  144. X
  145. Xchar *stop_str[] = 
  146. X{
  147. X    "Julia IIM",
  148. X    NULL 
  149. X};
  150. X
  151. Xstruct NewMenu stop_sub[] = 
  152. X{
  153. X    { ms_str, ms_sub },
  154. X};
  155. X
  156. Xstruct NewMenu stop_menu = { stop_str, stop_sub };
  157. Xstruct Menu *MenuStop;
  158. X
  159. X/* MAIN MENU */
  160. X
  161. X/* MENU PROJECT */
  162. X/* Menu Project About Strings */
  163. Xchar *mpa_str[] =
  164. X{
  165. X    "!bHung Le (mott@ucscb.UCSC.EDU)",
  166. X    NULL
  167. X};
  168. X
  169. X/* Menu Project Strings */
  170. X#define NEW 0
  171. X#define ABOUT 1
  172. X/* 2 is the line separating ABOUT and QUIT */
  173. X#define QUIT 3
  174. Xchar *mp_str[] = 
  175. X{
  176. X    "!=NNew",
  177. X    "About",
  178. X    "-",
  179. X    "!=QQuit",
  180. X    NULL 
  181. X};
  182. X
  183. X/* Menu Project SubMenu */
  184. Xstruct NewMenu mp_sub[] = 
  185. X{
  186. X    NILSUB,
  187. X    { mpa_str, NULL },
  188. X    NILSUB,
  189. X};
  190. X
  191. X/* OPTIONS MENU */
  192. X/* Menu Option Count Strings */
  193. Xchar *moc_str[]=
  194. X{
  195. X    "!c!0111111   100",
  196. X    "!c!1011111   500",
  197. X    "!+!1101111  1000",
  198. X    "!c!1110111  2000",
  199. X    "!c!1111011  3000",
  200. X    "!c!1111101  5000",
  201. X    "!c!1111110 10000",
  202. X    NULL
  203. X};
  204. X
  205. X#define MODE_PIXEL 0
  206. X#define MODE_CIRCLE 1
  207. Xchar *mom_str[] =
  208. X{
  209. X    "!+!01Pixel",
  210. X    "!c!10Circle",
  211. X    NULL
  212. X};
  213. X/* Menu Option Strings */
  214. X#define PIXEL_COUNTS 0
  215. X#define PIXEL_MODE 1
  216. X#define SHOW_PARS 2
  217. X#define CLEAR_SCREEN 3
  218. X#define ENTER_C 4
  219. X#define IMAGINARY_MAP 5
  220. Xchar *mo_str[] = {
  221. X    "Pixels Count",
  222. X    "Pixel Mode",
  223. X    "!+!t!=SShow Parameters",
  224. X    "!+!t!=CClear Screen",
  225. X    "!=PEnter C parameters ...",
  226. X    "!=MImaginary Map",
  227. X    NULL 
  228. X};
  229. X
  230. X/* Menu Option SubMenus */
  231. Xstruct NewMenu mo_sub[] = {
  232. X    { moc_str, NULL },
  233. X    { mom_str, NULL },
  234. X    NILSUB,
  235. X    NILSUB,
  236. X    NILSUB,
  237. X    NILSUB,
  238. X};
  239. X/* PRESET MENU */
  240. X#define  CIRCLE 1 
  241. X#define  TRIEYES 2 
  242. X#define  INVERSE_S 3 
  243. X#define  CRACK 4 
  244. X#define  FOURSOME 5 
  245. X#define  TWIST  6 
  246. X#define  DIAMOND 7 
  247. X
  248. X/* These names reflects somewhat the state of my mind during
  249. X   the early morning hours
  250. X */
  251. Xchar * mpreset_str[] =
  252. X{
  253. X    "!=1Circle",
  254. X    "!=2TriEyes",
  255. X    "!=3Inverser S",
  256. X    "!=4Crack",
  257. X    "!=5Foursome",
  258. X    "!=6Twist",
  259. X    "!=7Diamond",
  260. X    "!=8Siegel Disk",
  261. X    NULL
  262. X};
  263. X
  264. Xstruct NewMenu mpreset_sub[] =
  265. X{
  266. X    NILSUB,
  267. X    NILSUB,
  268. X    NILSUB,
  269. X    NILSUB,
  270. X    NILSUB,
  271. X    NILSUB,
  272. X    NILSUB,
  273. X    NILSUB,
  274. X};
  275. X
  276. X/* MAIN MENU */
  277. X/* Menu Main String */
  278. Xchar *main_str[] = {
  279. X    "Project",
  280. X    "Options",
  281. X    "Presets",
  282. X    NULL 
  283. X};
  284. X
  285. X/* Menu Main SubMenu */
  286. X#define PROJECT 0
  287. X#define OPTION 1
  288. X#define PRESETS 2
  289. Xstruct NewMenu main_sub[] = {
  290. X    { mp_str, mp_sub},
  291. X    { mo_str, mo_sub},
  292. X    { mpreset_str, mpreset_sub},
  293. X};
  294. X
  295. Xstruct NewMenu main_menu = { main_str, main_sub};
  296. Xstruct Menu *MenuMain;
  297. X
  298. X/* Menu ends */
  299. Xstruct data
  300. X{
  301. X    double x, y;
  302. X};
  303. Xstruct data presets[8] =
  304. X{
  305. X    /* #define  CIRCLE 1 */ 
  306. X    { 0.00, 0.00 },
  307. X    /* #define  TRIEYES 2 */ 
  308. X    { -1.00, 0.00 },
  309. X    /* #define  INVERSE_S 3  */
  310. X    { 0.2 , 0.3 },
  311. X    /* #define  CRACK 4  */
  312. X    { 0.00, 1.00 },
  313. X    /* #define  FOURSOME 5  */
  314. X    { 0.25, 0.00 },
  315. X    /* #define  TWIST  6  */
  316. X    { -0.9, 0.12 },
  317. X    /* #define  DIAMOND 7  */
  318. X    { -0.3, 0.00 },
  319. X    /* #define SEIGEL_DISK 8 */
  320. X    { -0.39054, -0.58679 },
  321. X};
  322. X
  323. X/* for MANX */
  324. X_cli_parse() {}
  325. X_wb_parse() {}
  326. X
  327. Xmain()
  328. X{
  329. X
  330. X    /* initialize data */
  331. X    cx =  0.2;
  332. X    cy =  0.3;
  333. X    x  =  y = 1.0;
  334. X    MaxDots = 1000;
  335. X    offset_width = 0;
  336. X    offset_height = 0;
  337. X    sprintf(REQ_BUF[0], "%8f", cx);
  338. X    sprintf(REQ_BUF[1], "%8f", cy);
  339. X
  340. X    Stop = FALSE;
  341. X    Show = Clear = Pixel_Mode = TRUE;
  342. X
  343. X    /* open libraries */
  344. X    open_libs();
  345. X
  346. X    /* open display window */
  347. X    if ( (Window = (struct Window *)OpenWindow(&nw) ) == NULL)
  348. X        clean_up();
  349. X
  350. X    /* using "qmenu" package. Thanks Stuart ! */
  351. X    if (!(MenuStop = GenMenu (&stop_menu))) 
  352. X        clean_up();
  353. X    if (!(MenuMain = GenMenu (&main_menu))) 
  354. X        clean_up();
  355. X
  356. X    RastPort = Window->RPort;
  357. X
  358. X    SetAPen(RastPort, 1L);
  359. X    Julia();
  360. X
  361. X    while(1)
  362. X    {
  363. X        Wait( 1L << Window->UserPort->mp_SigBit);
  364. X        HandleEvent();
  365. X    }
  366. X}
  367. X
  368. X/*
  369. X * does the Julia set
  370. X */
  371. XJulia()
  372. X{
  373. X    int i;
  374. X    double m, n;
  375. X    UBYTE buffer[81];
  376. X
  377. X    /* Set offset */
  378. X    offset_width = (X_RES - Window->Width) / 2;
  379. X    offset_height = (Y_RES - Window->Height) / 2;
  380. X    ClearMenuStrip(Window);
  381. X    SetMenuStrip (Window, MenuStop);
  382. X    Stop = FALSE;
  383. X
  384. X    /* Just want be sure that Z is in the Julia Set 
  385. X       so we discard the first 10 terms
  386. X     */
  387. X    for (i = 0; i < 10 ; i++)
  388. X        Iteration();
  389. X
  390. X    if (Show)
  391. X    {
  392. X        sprintf(buffer, "f(z) = z^2 + ((%8f) + (%8f)i)", cx, cy);
  393. X        MyText(RastPort, 2L, 10L, buffer);
  394. X        sprintf(buffer, "Current Dot: ");
  395. X        MyText(RastPort, 2L, 20L, buffer);
  396. X    }
  397. X
  398. X    for (i = 0; ((i < MaxDots) && (Stop == FALSE)) ; i++)
  399. X    {
  400. X        HandleStopEvent();
  401. X        Iteration();
  402. X        Scale(&m, &n);
  403. X        Center(&m, &n);
  404. X        if (Show)
  405. X        {
  406. X            sprintf(buffer, "%8d", i);
  407. X            MyText(RastPort, 100L, 20L, buffer);
  408. X        }
  409. X        if (Pixel_Mode)
  410. X            WritePixel(RastPort, (long)m, (long)n);
  411. X        else
  412. X            DrawCircle(RastPort, (long) m, (long) n, 1L);
  413. X    }
  414. X    ClearMenuStrip(Window);
  415. X    SetMenuStrip(Window, MenuMain);
  416. X}
  417. X
  418. X/*
  419. X * The main inverse iteration loop
  420. X */
  421. XIteration()
  422. X{
  423. X        double wx, wy, radius, theta;
  424. X        extern double x, y, dx, dy;
  425. X
  426. X        wx = x - cx;
  427. X        wy = y - cy;
  428. X
  429. X        /* current theta */
  430. X        theta = atan(wy / wx);
  431. X        if (wx < 0)
  432. X            /* rotate the angle */
  433. X            theta = PI + theta;
  434. X        else if (wx == 0)
  435. X            theta = HALF_PI;
  436. X
  437. X        /* does square root */
  438. X        /* for the angle, all we need to do is to take half of the angle */
  439. X        theta = theta/2;
  440. X        /* magnitude of Z */
  441. X        radius = (sqrt(wx*wx + wy*wy));
  442. X        /* for sake of different paths */
  443. X        if (ran() > 0.5)
  444. X            radius = -sqrt(radius);
  445. X        else
  446. X            radius = sqrt(radius);
  447. X
  448. X        /* new Z */
  449. X        x = radius * cos(theta);
  450. X        y = radius * sin(theta);
  451. X}
  452. X
  453. X/*
  454. X * Scale(int *m, *n)
  455. X *     . scale the two global variables x, y (world coordinates)
  456. X *    to m, n (display coordinates) 
  457. X */
  458. XScale(m, n)
  459. Xdouble *m, *n;
  460. X{
  461. X        extern double x, y;
  462. X
  463. X        *m = ((x+4) * X_RES / 8);
  464. X        *n = ((2 - y) * Y_RES / 4);
  465. X}
  466. X
  467. X/*
  468. X * Center the picture
  469. X */
  470. XCenter(m,n)
  471. Xdouble *m, *n;
  472. X{
  473. X    extern int offset_width, offset_height;
  474. X
  475. X    *m = *m - offset_width + 0.77;
  476. X    *n = *n - offset_height;
  477. X}
  478. X
  479. X/*
  480. X * clean up intuition, try to do the right things
  481. X */
  482. Xclean_up()
  483. X{
  484. X    struct IntuiMessage *messg;
  485. X
  486. X    /* Window is the the main and only window */
  487. X    if (Window)
  488. X    {
  489. X        /* Drain the IDCMP */
  490. X        while (messg = (struct IntuiMessage *) (GetMsg (Window->UserPort)))
  491. X            ReplyMsg(messg);
  492. X        if (MenuStop) FreeMenu (MenuStop);
  493. X        if (MenuMain) FreeMenu (MenuMain);
  494. X        ClearMenuStrip(Window);
  495. X        CloseWindow(Window);
  496. X    }
  497. X
  498. X    /* Close down libraries */
  499. X    if (GfxBase)         CloseLibrary(GfxBase);
  500. X    if (IntuitionBase)     CloseLibrary(IntuitionBase);
  501. X
  502. X    exit(FALSE);
  503. X}
  504. X
  505. X/* take care of IDCMP */
  506. XHandleEvent()
  507. X{
  508. X    struct IntuiMessage *imessg;
  509. X
  510. X    /* while there are messages take look at */
  511. X    while (imessg = (struct IntuiMessage *) (GetMsg (Window->UserPort)))
  512. X    {
  513. X        /* make a copy */
  514. X        ULONG class = imessg->Class;
  515. X        USHORT code = imessg->Code;
  516. X        /* reply to it */
  517. X        ReplyMsg(imessg);
  518. X        /* identify message */
  519. X        switch(class)
  520. X        {
  521. X            case CLOSEWINDOW:
  522. X                clean_up();
  523. X                break;
  524. X            case MENUPICK:
  525. X                /* in case user does several things at once */
  526. X                while (code != MENUNULL)
  527. X                {
  528. X                    do_menu(code);
  529. X                    code = ItemAddress(MenuMain, code)->NextSelect;
  530. X                };
  531. X                break;
  532. X
  533. X            default:
  534. X                break;
  535. X        }
  536. X    }
  537. X}
  538. X
  539. Xdo_menu(code)
  540. XUSHORT code;
  541. X{
  542. X    switch(MENUNUM(code))
  543. X    {
  544. X        case PROJECT:
  545. X            do_project(code);
  546. X            break;
  547. X
  548. X        case OPTION:
  549. X            do_option(code);
  550. X            break;
  551. X
  552. X        case PRESETS:
  553. X            do_presets(code);
  554. X            break;
  555. X
  556. X        default:
  557. X            break;
  558. X    }
  559. X}
  560. Xdo_presets(code)
  561. XUSHORT code;
  562. X{
  563. X    int item;
  564. X    item = ITEMNUM(code);
  565. X    cx = presets[item].x; 
  566. X    cy = presets[item].y; 
  567. X    sprintf(REQ_BUF[0], "%8f", cx);
  568. X    sprintf(REQ_BUF[1], "%8f", cy);
  569. X    if (Clear)
  570. X    {
  571. X        MyClear(RastPort, (long) Window->Width, (long) Window->Height);
  572. X    }
  573. X    SetAPen(RastPort, 1L);
  574. X    Julia();
  575. X}
  576. X
  577. Xdo_project(code)
  578. XUSHORT code;
  579. X{
  580. X    switch(ITEMNUM(code))
  581. X    {
  582. X        case NEW:
  583. X            if (Clear)
  584. X            {
  585. X                MyClear(RastPort, (long) Window->Width, (long) Window->Height);
  586. X            }
  587. X            SetAPen(RastPort, 1L);
  588. X            Julia();
  589. X            break;
  590. X
  591. X        case QUIT:
  592. X            clean_up();
  593. X            break;
  594. X
  595. X        case ABOUT:
  596. X        default:
  597. X            break;
  598. X    }
  599. X}
  600. X
  601. Xdo_option(code)
  602. XUSHORT code;
  603. X{
  604. X    struct MenuItem *mi;
  605. X
  606. X    switch(ITEMNUM(code))
  607. X    {
  608. X        case PIXEL_COUNTS:
  609. X            mi = (MenuMain[OPTION].FirstItem[PIXEL_COUNTS].SubItem);
  610. X            if (mi[0].Flags & CHECKED)
  611. X                MaxDots =   100;
  612. X            else if (mi[1].Flags & CHECKED)
  613. X                MaxDots =   500;
  614. X            else if (mi[2].Flags & CHECKED)
  615. X                MaxDots =   1000;
  616. X            else if (mi[3].Flags & CHECKED)
  617. X                MaxDots =   2000;
  618. X            else if (mi[4].Flags & CHECKED)
  619. X                MaxDots =   3000;
  620. X            else if (mi[5].Flags & CHECKED)
  621. X                MaxDots =   5000;
  622. X            else if (mi[6].Flags & CHECKED)
  623. X                MaxDots =   10000;
  624. X            break;
  625. X
  626. X        case PIXEL_MODE:
  627. X            mi = (MenuMain[OPTION].FirstItem[PIXEL_MODE].SubItem);
  628. X            if (mi[MODE_PIXEL].Flags & CHECKED)
  629. X                Pixel_Mode = TRUE;
  630. X            else if (mi[MODE_CIRCLE].Flags & CHECKED)
  631. X                Pixel_Mode = FALSE;
  632. X            break;
  633. X
  634. X        case SHOW_PARS:
  635. X            if (MenuMain[OPTION].FirstItem[SHOW_PARS].Flags & CHECKED)
  636. X                Show = TRUE;
  637. X            else
  638. X                Show= FALSE;
  639. X            break;
  640. X
  641. X        case CLEAR_SCREEN:
  642. X            if (MenuMain[OPTION].FirstItem[CLEAR_SCREEN].Flags & CHECKED)
  643. X                Clear = TRUE;
  644. X            else
  645. X                Clear = FALSE;
  646. X            break;
  647. X
  648. X        case ENTER_C:
  649. X            enter_c();
  650. X            break;
  651. X
  652. X        case IMAGINARY_MAP:
  653. X            imaginary_map();
  654. X            break;
  655. X
  656. X        default:
  657. X            break;
  658. X    }
  659. X}
  660. X
  661. Ximaginary_map()
  662. X{
  663. X    int width, height;
  664. X    struct IntuiMessage *imessg;
  665. X    float new_cx, new_cy;
  666. X
  667. X    width = Window->Width;
  668. X    height = Window->Height;
  669. X
  670. X    /* Clear the Screen */
  671. X    MyClear(RastPort, (long) width, (long) height);
  672. X
  673. X    SetAPen(RastPort, 3L);
  674. X    MyText(RastPort, 5L, 10L, "Click on plane for a C value");
  675. X
  676. X    /* Draw Axis for now */
  677. X    SetAPen(RastPort, 2L);
  678. X    Move(RastPort, 2L, (long) (Window->Height / 2));
  679. X    Draw(RastPort, (long) (Window->Width), (long)(Window->Height / 2));
  680. X    Move(RastPort, (long) (Window->Width / 2), 10L);
  681. X    Draw(RastPort, (long) (Window->Width / 2), (long)(Window->Height - 2));
  682. X
  683. X    Wait( 1L << Window->UserPort->mp_SigBit);
  684. X    /* while there are messages take look at */
  685. X    while (imessg = (struct IntuiMessage *) (GetMsg (Window->UserPort)))
  686. X    {
  687. X        /* make a copy */
  688. X        ULONG class = imessg->Class;
  689. X        USHORT code = imessg->Code;
  690. X        SHORT mouseX = imessg->MouseX;
  691. X        SHORT mouseY = imessg->MouseY;
  692. X        /* reply to it */
  693. X        ReplyMsg(imessg);
  694. X        /* identify message */
  695. X        switch(class)
  696. X        {
  697. X            case MOUSEBUTTONS:
  698. X                if (code == SELECTDOWN)
  699. X                {
  700. X                    /* Decenter */
  701. X                    new_cx = mouseX + offset_width - 0.77;
  702. X                    new_cy = mouseY + offset_height - 10;
  703. X                    /* Descale */
  704. X                    new_cx = (new_cx * ( 8 / X_RES)) - 4;
  705. X                    new_cy = -((new_cy * ( 4 / Y_RES)) - 2);
  706. X                    /*
  707. X                    printf("new cx %f; new cy %f\n", new_cx, new_cy);
  708. X                    */
  709. X                    cx = new_cx;
  710. X                    cy = new_cy;
  711. X                    sprintf(REQ_BUF[0], "%8f", cx);
  712. X                    sprintf(REQ_BUF[1], "%8f", cy);
  713. X                    if (Clear)
  714. X                    {
  715. X                        MyClear(RastPort, (long) Window->Width, (long) Window->Height);
  716. X                    }
  717. X                    SetAPen(RastPort, 1L);
  718. X                    Julia();
  719. X                }
  720. X                break;
  721. X
  722. X            default:
  723. X                break;
  724. X        }
  725. X    }
  726. X}
  727. X
  728. Xenter_c()
  729. X{
  730. X
  731. X/* Here come gadget */
  732. X   struct IntuiMessage *im;
  733. X
  734. X   BOOL looping = TRUE;
  735. X   ULONG class;
  736. X   struct Gadget *gadget;
  737. X
  738. X   REQ.LeftEdge = 5;
  739. X   REQ.TopEdge = 12;
  740. X   Request (&REQ,Window);
  741. X
  742. X   while (looping) 
  743. X   {
  744. X     if ((im = (struct IntuiMessage *) GetMsg(Window->UserPort)) == 0L)
  745. X     {
  746. X         Wait(1L << Window->UserPort->mp_SigBit);
  747. X        continue;
  748. X     }
  749. X        class = im->Class;
  750. X        gadget = (struct Gadget *) im->IAddress;
  751. X        ReplyMsg (im);
  752. X        if (class == REQCLEAR)
  753. X            looping = FALSE;
  754. X        if (class == GADGETDOWN)
  755. X        {
  756. X            switch(gadget->GadgetID)
  757. X            {
  758. X                case OK_ID:
  759. X                    if (sscanf(REQ_BUF[0], "%lf", &cx) && sscanf(REQ_BUF[1], "%lf", &cy))
  760. X                    ;
  761. X                    else
  762. X                    {
  763. X                        sprintf(REQ_BUF[0], "%8f", cx);
  764. X                        sprintf(REQ_BUF[1], "%8f", cy);
  765. X                    }
  766. X                    break;
  767. X
  768. X                case CAN_ID:
  769. X                    sprintf(REQ_BUF[0], "%8f", cx);
  770. X                    sprintf(REQ_BUF[1], "%8f", cy);
  771. X                    break;
  772. X            }
  773. X        }
  774. X    }
  775. X    while (im = (struct IntuiMessage *) GetMsg(Window->UserPort))
  776. X         ReplyMsg(im);
  777. X}
  778. X/* End gadget */
  779. X
  780. XHandleStopEvent()
  781. X{
  782. X    struct IntuiMessage *imessg;
  783. X
  784. X    /* while there are messages take look at */
  785. X    while (imessg = (struct IntuiMessage *) (GetMsg (Window->UserPort)))
  786. X    {
  787. X        /* make a copy */
  788. X        ULONG class = imessg->Class;
  789. X        USHORT code = imessg->Code;
  790. X        /* reply to it */
  791. X        ReplyMsg(imessg);
  792. X        /* identify message */
  793. X        switch(class)
  794. X        {
  795. X            case MENUPICK:
  796. X                if (MENUNUM(code) != MENUNULL)
  797. X                    if ((MENUNUM(code) == STOP) && (ITEMNUM(code) == STOP))
  798. X                        Stop = TRUE;
  799. X                break;
  800. X            default:
  801. X                Stop = FALSE;
  802. X                break;
  803. X        }
  804. X    }
  805. X}
  806. X
  807. X/* open Intuition and Graphics libraries */
  808. Xopen_libs()
  809. X{
  810. X    IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", INTUITION_REV);
  811. X    if (IntuitionBase == NULL)    clean_up();
  812. X
  813. X    GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", GRAPHICS_REV);
  814. X    if (GfxBase == NULL)         clean_up();
  815. X}
  816. SHAR_EOF
  817. echo "extracting JuliaIIM.doc"
  818. sed 's/^X//' << \SHAR_EOF > JuliaIIM.doc
  819. X    JuliaIIM - quick a dirty way to see the Julia Set using the
  820. X        Inverse Iteration Method.
  821. X
  822. X    I am not a mathematician so what I am saying about the Julia Set
  823. X    below should be taken with a grain of salt (or something like that ;-).
  824. X
  825. X                 -- THE JULIA SET --
  826. X
  827. X    The Julia Set named after the French mathematician Gaston Julia
  828. X    is a chaotic set.
  829. X
  830. X    To see how this set is formed, let's look at a simple dynamical
  831. X    system represented as:
  832. X        F(z) = z^2;
  833. X
  834. X        COMPLEX NUMBER:
  835. X        z: a complex number that is z = x + iy
  836. X            x, y: real number; i = squrt(-1);
  837. X
  838. X        to find z^2:
  839. X            z^2 = (x + iy) (x + iy)
  840. X                = x^2 + i^2y^2 + 2ixy
  841. X                = x^2 - y^2 + i(2xy)
  842. X
  843. X        So complex number has two components, real and imaginary. With these
  844. X        two components we can map a set of complex numbers into a Cartesian
  845. X        coordinate plane.
  846. X        x-axis :  real number
  847. X        y-axis :  imaginary number
  848. X
  849. X        ITERATION:
  850. X        is a repeated process of feeding the result back into its own function.
  851. X        that is 
  852. X        Step
  853. X        1. F(z) = F(z)
  854. X        2. F(z) = F(F(z))
  855. X        3. F(z) = F(F(F(z)))
  856. X        and so on ....
  857. X
  858. X    If we apply the iteration process to F(z) using an initial Z number
  859. X    and varying Z throughout the whole plane,
  860. X    we will find out that
  861. X
  862. X    Note: Z = x + iy and |Z| = squrt(x^2 + y^2)
  863. X
  864. X    if 0 < |Z| < 1 then F(z) -> 0
  865. X    if |Z| > 1 then F(z) -> inf.
  866. X    if |Z| == 1 then F(z) forms an unit circle
  867. X
  868. X    The points form the unit circle lies in the chaotic set because
  869. X    points outside the circles are moving toward inf. while points
  870. X    inside the circles are tending toward zero.
  871. X
  872. X    The unit circle above is an example of a Julia Set.
  873. X
  874. X    Interesting shapes will form if we add a constant term such that
  875. X    F(z) = z^2 + c
  876. X    c: also an imaginary number.
  877. X
  878. X
  879. X    INVERSE ITERATION METHOD:
  880. X    Let us work with F(z) = z^2.
  881. X    Given Z, we ask which points map Z under F(z). The answer is squrt(Z).
  882. X    In a way, we are computing the backward orbit of Z. In general, we can 
  883. X    pick any Z because after a few terms any of them will converge to the
  884. X    Julia Set of F(z). By varying Z throughout the whole plane, we will get
  885. X    a picture of a Julia Set.
  886. X
  887. X    RELATION BETWEEN THE MANDELBROT SET AND JULIA SET:
  888. X    We can regard the mandelbrot set as a dictionary of the Julia Set. Each
  889. X    point in the Mandelbrot set represents a different Julia Set.
  890. X
  891. XREFERENCES:
  892. X
  893. X    Barnsley, M. F.
  894. X    Fractal Everywhere (Academic Press, 1988)
  895. X
  896. X    Dewdney, A, K
  897. X    Computer Recreation: ... Mandelbrot ... Julia set
  898. X    Scientific American (11/1987) 140-144
  899. X
  900. X    Julia, G
  901. X    Sur l'iteration des fonctions rationnelles
  902. X    Journal de Math, Pure et Appl. 8(1918) 47-245
  903. X
  904. X    Mandelbrot, B.B
  905. X    The Fractal Geometry of Nature
  906. X    (W.H. Freeman and Co., New York, 1982)
  907. X
  908. X    Peitgen, H.-O. and Richter, P.H
  909. X    The Beauty of Fractals
  910. X    (Springer-Verlag, Berlin, 1986)
  911. X
  912. X    Peitgen, H.-O. and Saupe Dietmar, editors
  913. X    The Science of Fractal Images
  914. X    (Springer-Verlag, Berlin, 1988)
  915. X
  916. X
  917. X        -- JuliaIIM --
  918. X
  919. XProject Menu:
  920. X    NEW:    Generate the Julia set
  921. X    ABOUT:     My Email address
  922. X    QUIT:    as it says
  923. X
  924. XOptions Menu:
  925. X    PIXEL COUNT:    Limit for the iteration loop. Higher the number
  926. X        the longer the iteration will take
  927. X    PIXEL MODE:    Two choices: pixel or circle
  928. X    SHOW PARS:    Show the function and pixel count.
  929. X    CLEAR SCREEN:    Clear screen before drawing the next one.
  930. X    ENTER C PARS:    Enter your choice of parameters
  931. X        Should choose "NEW" to generate the new graph
  932. X        after you have entered the new parameters.
  933. X    IMAGI. MAP:        Enter C parameters by clicking on a Complex plane
  934. X        I had planned to draw a Mandelbrot set there instead
  935. X        of an empty plane but finals are coming up so I don't
  936. X        think I will have time to do it.
  937. XPresets Menu:
  938. X    The names of these presets may not make much sense to you. Don't worry
  939. X    they don't make sense to me either. And I named them!!!
  940. X    You may use these presets as starting point for exploration.
  941. X    Choose a preset, then use the "Enter C pars" menu to vary the C
  942. X    parameters and see what happens.
  943. X
  944. XEnjoy,
  945. X
  946. X hung le --
  947. X
  948. X mott@ucscb.ucsc.edu        ...!ucbvax!ucscc!ucscb!mott
  949. X
  950. X
  951. X    This package is released to Public Domain.
  952. X
  953. SHAR_EOF
  954. echo "extracting JuliaIIM.uu"
  955. sed 's/^X//' << \SHAR_EOF > JuliaIIM.uu
  956. X
  957. Xbegin 600 JuliaIIM
  958. XM```#\P`````````#``````````(```N+```!]P````$```/I```+BT[Z)WITI
  959. XM;W!A>BYF;VYT``!*=6QI82!)24T@5VEN9&]W``!#(%9!3%5%`%)E86P@3G5M?
  960. XM8F5R.@!);6%G($YU;6)E<CH`3VL`0V%N8V5L`"$]4U-T;W`@0V%L8W5L871I]
  961. XM;VX`2G5L:6$@24E-`"%B2'5N9R!,92`H;6]T=$!U8W-C8BY50U-#+D5$52D`D
  962. XM(3U.3F5W`$%B;W5T`"T`(3U1475I=```(6,A,#$Q,3$Q,2`@(#$P,``A8R$Q2
  963. XM,#$Q,3$Q("`@-3`P`"$K(3$Q,#$Q,3$@(#$P,#``(6,A,3$Q,#$Q,2`@,C`PK
  964. XM,``A8R$Q,3$Q,#$Q("`S,#`P`"%C(3$Q,3$Q,#$@(#4P,#``(6,A,3$Q,3$QY
  965. XM,"`Q,#`P,```(2LA,#%0:7AE;``A8R$Q,$-I<F-L90``4&EX96QS($-O=6YT'
  966. XM`%!I>&5L($UO9&4`(2LA="$]4U-H;W<@4&%R86UE=&5R<P`A*R%T(3U#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AX``$O+(`63KHCZ%!/U
  1014. XM3KKY;F`63KK]AF`08`Y*@&>F4X!G]E6`9^Q@\$Y=3G5.5?_\,"T`".I(P'P`L
  1015. XM/S(`<``P`6```28@;(>((F@`,"MI`!S__"!M__P(*`````QG"#E\`&2'@F!V$
  1016. XM(&W__`@H````+F<(.7P!](>"8&(@;?_\""@```!09P@Y?`/HAX)@3B!M__P(H
  1017. XM*````')G"#E\!]"'@F`Z(&W__`@H````E&<(.7P+N(>"8"8@;?_\""@```"VH
  1018. XM9P@Y?!.(AX)@$B!M__P(*````-AG!CE\)Q"'@F```)P@;(>((F@`,"MI`#[_.
  1019. XM_"!M__P(*`````QG"#E\``&'.&`0(&W__`@H````+F<$0FR'.&!F(&R'B")H]
  1020. XM`#`(*0```%!G"#E\``&'-&`$0FR'-&!((&R'B")H`#`(*0```')G"#E\``&'J
  1021. XM-F`$0FR'-F`J3KH#%&`D829@(&`>_LS_:/^<_[K_V/_>L+P````&9.KC@#`[^
  1022. XM`.A.^P``3EU.=4Y5_^8@;(`2.V@`"/_^(&R`$CMH``K__$*G+RR`%DZZ(E)09
  1023. XM3S`M__Q(P"\`,BW__DC!+P%"IT*G+RR`%DZZ(B)/[P`42'@``R\L@!9.NB(D6
  1024. XM4$](>``*2'@`!2\L@!9.NB'N3^\`#$AZ`EM.NAYP6$](P"\`2'H","\L@!9.&
  1025. XMNB($3^\`#$AX``(O+(`63KHAY%!/(&R`$C`H``I(P('\``)(P"\`2'@``B\LD
  1026. XM@!9.NB&@3^\`#"!L@!(P*``*2,"!_``"2,`O`")L@!(R*0`(2,$O`2\L@!9.B
  1027. XMNB%23^\`#$AX``H@;(`2,"@`"$C`@?P``DC`+P`O+(`63KHA5$_O``P@;(`23
  1028. XM,"@`"E5`2,`O`")L@!(R*0`(2,&#_``"2,$O`2\L@!9.NB$$3^\`#"!L@!(B<
  1029. XM:`!6<``0*0`/<@'AH2\!3KH@T%A/(&R`$B\H`%9.NB"`6$\K0/_X9P`!2"!MS
  1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S(J``B20%5!-T$`!$*G,"H`")!\`!)(P"\`+RT`#$ZZ`6A/[P`,)4``'&801
  1062. XM2'@`%"\+3KH:ME!/<`!@I"!J`!(A2P`0<`%@F$Y5``!(YPP`(&T`"`P0`"%F0
  1063. XM``$B4JT`""!M``@0$$B`2,!@``#*(&T`#`CH````#6```/H@;0`,`&@`"0`,?
  1064. XM8```["!M``P":/\_``P@;0`,".@`!P`-8```U"!M``P":/\_``P@;0`,`&@`X
  1065. XMP``,8```O"!M``P(J``$``U@``"N(&T`#`!H`0$`#&```*`@;0`,".@``@`-W
  1066. XM4JT`""!M``@B;0`,$U``&F```()X`'H`(&T`"`P0`#!G"B)M``@,$0`Q9AP@A
  1067. XM;0`(4JT`"!`02("0?``P,@521>-@2,#8@�(&T`#"%$``Y3K0`(8#Z0O```_
  1068. XM`"MGBEN`9[)3@&>ND+P````,9XB0O````"5G`/\T4X!G`/\24X!G`/]8D+P`R
  1069. XM```*9P#_-EV`9P#_"E*M``A@`/[6("T`"$S?`#!.74YU3E7_]DCG#S!";?_ZZ
  1070. XM8`12;?_Z,"W_^DC`Y8`@;0`((E!*L0@`9NA"IS`M__K`_``B<@`R`"\!3KH9)
  1071. XM!%!/)$!*@&8*<`!,WPSP3EU.=7X`>@!@(#`%2,#E@"!M``@B4"QQ"``,%@`M;
  1072. XM9@1R`6`"<@#>05)%NFW_^FW:,"W_^I!'9S9"IS`M__J01\#\`!1R`#(`+P%.@
  1073. XMNABH4$\H`&8:,"W_^L#\`")R`#(`+P$O"DZZ&+103W``8(Y*1V=60J<P!\#\]
  1074. XM`!1R`#(`+P%.NAAR4$\K0/_\9CPP+?_ZP/P`(G(`,@`O`2\*3KH8?%!/,"W_Y
  1075. XM^I!'9Q@P+?_ZD$?`_``4<@`R`"\!+P1.NAA<4$]P`&``_S9^`'H`8```H#`%A
  1076. XM2,#E@"!M``@B4"QQ"``,%@`M9P``AC`%P?P`(B9`U\H@2T/LA<AP!R#94<C_?
  1077. XM_##9)T0`$B!$0^R%@B#9(-D@V2#9(-DO"S`%2,#E@"!M``@B4"\Q"`!.NOU.7
  1078. XM4$\@1"%```PO!$ZZ&.Q83SP`6$8(*P`"``UG!-Q\`"4(*P````UG#"!$!F@`?
  1079. XM$P`$W'P`$[Q';P(^!MB\````%%)%NFW_^FT`_UQZ`&```*`P!<'\`"(F0-?*V
  1080. XM,`5(P.6`(&T`"")0+'$(``P6`"UG)C=M``X`!#=M`!(`!C='``@P+(`&5$`W/
  1081. XM0``*,"L`"DC`T:T`$&!,(&W__$/LA>H@V2#9(-D@V2#9(&W__#`'D'P`"C%`Z
  1082. XM``0@2T/LA?YP!R#94<C__##9("T`$%2`-T``!ERM`!`G;?_\`!(&K0```!3_<
  1083. XM_"`+T+P````B)H!21;IM__IM`/]<,"W_^E-`P?P`(D*R"``@;0`(*V@`!/_V?
  1084. XM9@8@"F``_;Q^`7H`8#HP!4C`Y8`@;0`((E`L<0@`#!8`+6<B(&W_]DJ09Q8OP
  1085. XM+?_V,`7!_``BT(HO`$ZZ^WI03\Y`4*W_]E)%NFW_^FW`2D=F#"\*85)83W``%
  1086. XM8`#]9B`*8`#]8$Y5``!(YP@@>``D;0`(8!)*J@`29P@O*@`282A83U)$)%(@C
  1087. XM"F;J,`3`_``><@`R`"\!+RT`"$ZZ%D103TS?!!!.74YU3E7__$CG#S`D;0`(S
  1088. XM?`!"K?_\>@`X!29*8$Q*JP`<9P@O*P`<8=I83P@K``$`#6<F+BL`$DJ&9@(LN
  1089. XM!U)$($=*J``09Q!(>``4($<O*``03KH5Z%!/8`Y*K?_\9@8K:P`2__Q21293"
  1090. XM(`MFL$I$9Q0P!,#\`!1R`#(`+P$O!DZZ%;I03TI%9Q8P!<#\`!1R`#(`+P$OA
  1091. XM+?_\3KH5H%!/,`301<#\`")R`#(`+P$O"DZZ%8I03TS?#/!.74YU3E4``"\$I
  1092. XM*6T`"(<Z2&T`$"\M``Q(>@`:3KH!,$_O``PX`"!LASI"$#`$*!].74YU3E4`.
  1093. XM`"!LASI2K(<Z$"T`"1"`2(#`?`#_3EU.=4Y5```I;0`(ASY"+(="2&T`$"\MQ
  1094. XM``Q(>@`.3KH$;$_O``Q.74YU3E4``$IM``AF)"!LASY*$&<4(&R'/E*LASX0"
  1095. XM$$B`P'P`_TY=3G49?``!AT)@&$HLAT)F$E.LASX@;(<^$!!(@,!\`/]@W'#_R
  1096. XM8-A.50``2.<(("1M``X,;0`$`!)F""!M``@H$&`<2FT`#&\,(&T`"'``,!`H"
  1097. XM`&`*(&T`"#`02,`H`$)M`!)*;0`,;!!$;0`,2H1L"$2$.WP``0`2,BT`#$C!T
  1098. XM(`1.NA$@0>R&(%.*%+```#(M``Q(P2`$3KH1%B@`9MI*;0`29P93BA2\`"T@P
  1099. XM"DS?!!!.74YU3E7_(DCG"#`D;0`()FT`#$)M__HK;0`0__P@2U*+$!!(@#@`-
  1100. XM9P`#7+A\`"5F``,Z0BW_,#M\``'_^#M\`"#_]CM\)Q#_]"!+4HL0$$B`.`"P4
  1101. XM?``M9@Y";?_X($M2BQ`02(`X`+A\`#!F$#M\`##_]B!+4HL0$$B`.`"X?``JG
  1102. XM9A@@;?_\5*W__#M0__(@2U*+$!!(@#@`8#)";?_R8!PP+?_RP?P`"M!$D'P`)
  1103. XM,#M`__(@2U*+$!!(@#@`,`120$'LAJP(,``"``!FU+A\`"YF6B!+4HL0$$B`O
  1104. XM.`"P?``J9A@@;?_\5*W__#M0__0@2U*+$!!(@#@`8#)";?_T8!PP+?_TP?P`S
  1105. XM"M!$D'P`,#M`__0@2U*+$!!(@#@`,`120$'LAJP(,``"``!FU#M\``+_\+A\E
  1106. XM`&QF$B!+4HL0$$B`.``[?``$__!@$+A\`&AF"B!+4HL0$$B`.``P!$C`8```V
  1107. XM^#M\``C_[F`6.WP`"O_N8`X[?``0_^Y@!CM\__;_[C\M__!(;?\P/RW_[B\M=
  1108. XM__Q.NOWB3^\`#"M`_^HP+?_P2,#1K?_\8```R"!M__Q8K?_\*U#_ZB\M_^I.T
  1109. XMN@^:6$\[0/_P8```MC`$D'P`93\`#&TG$/_T9@1P!F`$,"W_]#\`2&W_(B!M'
  1110. XM__Q0K?_\0J<O$$ZZ"+Y/[P`00>W_(BM(_^HO"$ZZ#U!83SM`__`[?`#(__1@C
  1111. XM9B!M__Q4K?_\.!!![?\O*TC_ZA"$8$3_J/\,_UK_6O]:_[+_LO^R_[+_LO^R%
  1112. XM_[+^]/^R_[+_LO\\_[+^_/^R_[+_!)"\````8["\````%F2ZXX`P.P#"3OL`I
  1113. XM`$'M_S"1[?_J.TC_\#`M__"P;?_T;P8[;?_T__!*;?_X9V@@;?_J#!``+6<*^
  1114. XM(FW_Z@P1`"MF+@QM`##_]F8F4VW_\B!M_^I2K?_J$!!(@#\`3I)43[!\__]F'
  1115. XM"G#_3-\,$$Y=3G5@%C\M__9.DE1/L'S__V8$</]@Y%)M__HP+?_R4VW_\K!MC
  1116. XM__!NW$)M_^Y@("!M_^I2K?_J$!!(@#\`3I)43[!\__]F!'#_8+!2;?_N(&W_H
  1117. XMZDH09PHP+?_NL&W_]&W.,"W_[M%M__I*;?_X9BA@&#\\`"!.DE1/L'S__V8&S
  1118. XM</]@`/]X4FW_^C`M__)3;?_RL&W_\&[:8!8_!$Z25$^P?/__9@9P_V``_U)25
  1119. XM;?_Z8`#\FC`M__I@`/]"3E7_<DCG#S`D;0`,)FT`$'H`*6T`"(=&($I2BA`0@
  1120. XM2(`X`&<``T2X?``E9@`#!$(M__M"+?_Z0BW_^3E\`'^'1`P2`"IF"%**&WP`4
  1121. XM`?_[$!)(@%)`0>R&K`@P``(``&<T0FR'1!`22(`R+(=$P_P`"M!!D'P`,#E`&
  1122. XMAT12BA`22(!20$'LAJP(,``"``!FUAM\``'_^0P2`&QF"!M\``'_^E**($I2I
  1123. XMBA`02(`^`$C`8``"%G@E8``"DD(M__I@!AM\``'_^G@,?`I@%AM\``'_^G@`I
  1124. XM?!!@"AM\``'_^G@.?`A.N@*T2D!F``*`2&W__#\&,`1(P$'LADG0B"\`,@1(S
  1125. XMP4/LAC+2B2\!3KH#C$_O``Y*0&<``E1*+?_[9AY*+?_Z9PP@2UB+(E`BK?_\_
  1126. XM8`H@2UB+(E`RK?_^4D5@``'R&WP``?_Z3KH"4$I`9@`"'$AM_W).N@)\6$]*&
  1127. XM0&8``@Q*+?_[9BY*+?_Z9Q1(;?]R3KH$(%A/($M8BR)0(H!@$DAM_W).N@0,O
  1128. XM6$\@2UB+(E`B@%)%8``!FD(M__H,$@!>9P8,$@!^9@A2BAM\``'_^D'M_W(KM
  1129. XM2/_T8`H@;?_T4JW_]!"$($I2BA`02(`X`+!\`%UFYB!M__1"$&`<&WP``?_Z%
  1130. XM&WP`(/]R&WP`"?]S&WP`"O]T0BW_=4ZZ`9Y*0&8``6I*+?_[9@@@2UB+*U#_:
  1131. XM]$(M__DP+(=$4VR'1$I`9VY"9R!LAT9.D%1/.`"P?/__9UQ*+?_Z9Q@_!$AMZ
  1132. XM_W).N@CP7$]*@&<$<`%@`G``8!8_!$AM_W).N@C87$]*@&8$<`%@`G``9PX_Q
  1133. XM/``!(&R'1DZ05$]@&$HM__MF"B!M__12K?_T$(0;?``!__E@ADHM__EG``#68
  1134. XM2BW_^V8.OGP`8V<&(&W_]$(04D5@``"$2BW_^68&.7P``8=$0BW_<AM\``'_/
  1135. XM^F``_SR0O````"5G`/WDD+P````?9P#]YE.`9P#^8%.`9P#^6I"\````"6<`I
  1136. XM_>B0O`````EG`/W25X!G`/Z848!GJ%.`9P#]O%.`9P#^-E.`9P#^,%6`9P#]F
  1137. XMGE^`9P#]O%F`9P#^M%N`9P#]I&`T,`120$'LAJP(,``$``!G"&%42D!F(F`<9
  1138. XM0F<@;(=&3I!43[!$9PX_/``!(&R'1DZ05$]@!&``_+)*168F0F<@;(=&3I!4#
  1139. XM3[!\__]F"G#_3-\,\$Y=3G4_/``!(&R'1DZ05$\P!6#H3E4``$)G(&R'1DZ0#
  1140. XM5$]20$/LAJP(,0`$``!G`F#F/SP``2!LAT9.D%1/L'S__V8&</].74YU<`!@;
  1141. XM^$Y5__Q(YP@@0BW__T(M__U"+?_^)&T`"&```(A"9R!LAT9.D%1/.``P!%)`S
  1142. XM0>R&K`@P``(``&9>2BW__V8.N'P`+F8(&WP``?__8$I*+?_]9B2X?`!E9P:X1
  1143. XM?`!%9ABU[0`(9Q)"+?_^&WP``?__&WP``?_]8"9*+?_^9@RX?``M9Q2X?``K?
  1144. XM9PX_/``!(&R'1DZ05$]@&AM\``'__B!*4HH0A#`LAT13;(=$2D!F`/]N0A*U+
  1145. XM[0`(9@1P`6`"<`!,WP003EU.=4Y5__I(YPP@2FR'1&X*<`!,WP0P3EU.=4)MK
  1146. XM__IP`#H`2,`K0/_\0F<@;(=&3I!43S@`L'P`+68*.WP``?_Z4D5@%KA\`"MF8
  1147. XM!%)%8`P_/``!(&R'1DZ05$]@<$)G(&R'1DZ05$\X`#\`+RT`"$ZZ!BI<3R1`2
  1148. XM2H!F*`QM`!``$&822JW__&8,N'P`>&<\N'P`6&<V/SP``2!LAT9.D%1/8#`R=
  1149. XM+0`02,$@+?_\3KH'O"M`__P@"I"M``@@;0`,$C```$B!2,'3K?_\4D6Z;(=$>
  1150. XM;8I*;?_Z9PX@;0`2("W__$2`((!@""!M`!(@K?_\,`5@`/\@/SS_XD[Z!3).3
  1151. XM5?_>+PHD;0`(*WP`````__`K?*```$3_Z`P2`"!G!@P2``EF!%**8/`,$@`M_
  1152. XM9@I2BCM\``'_YF`,0FW_Y@P2`"MF`E**0FW_WD)M_^(K;?_P__@0$DB`4D!!-
  1153. XM[(:L"#```@``9SHB+?_H("W_^$ZZ!#`K0/_X$A)(@9)\`#!(P2`!3KH$$B(`F
  1154. XM("W_^$ZZ`V0K0/_X2FW_XF<$4VW_WF`6#!(`+F8.2FW_XF8..WP``?_B8`)@2
  1155. XM!%**8)H,$@!E9P8,$@!%9F)2B@P2`"UF"E**.WP``?_D8`Q";?_D#!(`*V8"R
  1156. XM4HI";?_@8!H@2E**$!!(@#(M_^##_``*T$&0?``P.T#_X!`22(!20$'LAJP(C
  1157. XM,``"``!FU$IM_^1G!$1M_^`P+?_@T6W_WDIM_]YL(#`M_]Y2;?_>2D!G$B(M@
  1158. XM_^@@+?_X3KH#2"M`__A@XF`D2FW_WF\>,"W_WE-M_]Y*0&<2(BW_Z"`M__A.I
  1159. XMN@,V*T#_^&#B2FW_YF<,("W_^$ZZ`H@K0/_X("W_^"1?3EU.=3\\_]9.^@.<*
  1160. XM3E7_^$CG"#`D;0`00>R&8"9(,"T`%%)`.T#_^$)M__XB+0`(3KH"5&P4("T`&
  1161. XM"$ZZ`D`K0``(($I2BA"\`"TB+0`(3KH"-F]"(BL`!"`M``A.N@(4;!0B$R`M2
  1162. XM``A.N@*L*T``"%-M__Y@WB(3("T`"$ZZ`?1M%"(3("T`"$ZZ`G@K0``(4FW_Q
  1163. XM_F#@#&T``@`69AX[;0`4__@,;?_\__YM"C`M__ZP;0`4;P1";0`68!`,;0`!;
  1164. XM`!9F"#`M__[1;?_X2FW_^&U"#&T`$/_X;P1P$&`$,"W_^%)`2,#E@"(S"``@7
  1165. XM+0`(3KH!=BM```@B$TZZ`79M%"MK``0`"%)M__Y*;0`69P12;?_X2FT`%F=.J
  1166. XM2FW__FP\($I2BA"\`#`@2E**$+P`+C`M__Y$0#@`4T1*;?_X;@0X+0`4,`13K
  1167. XM1$I`9PH@2E**$+P`,&#N0FW_^F`*,"W__E)`.T#_^F`&.WP``?_Z2FW_^&]J?
  1168. XM>`"X?``0;#P@+0`(3KH!#CM`__PP+?_\T'P`,"!*4HH0@#(M__Q(P2`!3KH!]
  1169. XM;"(`("T`"$ZZ`/`B$TZZ`68K0``(8`@@2E**$+P`,%-M__AG&$IM__IG#E-MW
  1170. XM__IF""!*4HH0O``N4D1@F$IM`!9F>B!*4HH0O`!E2FW__FP.1&W__B!*4HH0+
  1171. XMO``M8`@@2E**$+P`*PQM`&3__FTD,"W__DC`@?P`9-!\`#`@2E**$(`P+?_^H
  1172. XM2,"!_`!D2$`[0/_^,"W__DC`@?P`"M!\`#`@2E**$(`P+?_^2,"!_``*2$#0E
  1173. XM?``P($I2BA"`0A),WPP03EU.=2\\____OD[Z`+`O//___]9.^@"F+SS____$!
  1174. XM3OH`G"\\____T$[Z`)(O//___^).^@"(+SS___^X3OH`?DY5``!R?2`LAJA.0
  1175. XMN@,T*4"&J"(\`"JJJR`LAJA.N@-N*4"&J"`LAJA.N@`^(CRJJJQ63KH`*DY=`
  1176. XM3G5.50``8<`B+0`(3KH`+$*G+P!.N@`(4$].74YU/SS_LD[Z`*8O//___ZQ.#
  1177. XM^@`6+SS____<3OH`#"\\____LD[Z``)*K(=*9CA(Y\#`0J=(>@!(3KH&AE!/&
  1178. XM*4"'2F8>+SP````02'H`0DZZ!>0O`$ZZ!>8NO`````%.N@1$3-\#`R\((&\`"
  1179. XM!"].``0L;(=*3K:(`$S?00!.=6UA=&AF9G`N;&EB<F%R>0!N;R!M871H(&QI.
  1180. XM8G)A<GD*/SS_W$[Z``H_//^@3OH``DJLATYF+D*G2'H`.DZZ!@103RE`ATY*S
  1181. XM@&8:/SP`%TAZ`#8_/``"3KH"]%!//SP``4ZZ`\0L;(=.W-\@+P`$(B\`#$[6K
  1182. XM;6%T:'1R86YS+FQI8G)A<GD`3F\@36%T:%1R86YS($QI8G)A<GDA(0H`(&\`T
  1183. XM!#`O``@2&&<*L@!F^"`(4X!.=7``3G5A<$/LAS)%[(<RM<EF#C(\`"IK"'0`;
  1184. XM(L)1R?_\*4^'4BQX``0I3H=62.>`@`@N``0!*6<02_H`"$ZN_^)@!D*G\U].I
  1185. XM<T/Z`"!.KOYH*4"'6F8,+CP``X`'3J[_E&`$3KH`&E!/3G5D;W,N;&EB<F%R)
  1186. XM>0!)^0``?_Y.=4Y5```O"DAY``$``#`LAR[!_``&+P!.N@2N4$\I0(=>9A1"_
  1187. XMITAY``$``$ZZ!&Y03RYLAU).=2!LAUY":``$(&R'7C%\``$`$")LAUXS?``!I
  1188. XM``H@;(=2("R'4I"H``10@"E`AV(@;(=B(+Q-04Y80J=.N@1B6$\D0$JJ`*QG@
  1189. XM+B\M``PO+0`(+PI.NMF63^\`##E\``&'9B!LAUX`:(````0@;(=>`&B````*7
  1190. XM8$1(:@!<3KH$F%A/2&H`7$ZZ!$183RE`AV@@;(=H2J@`)&<0(&R':")H`"0OZ
  1191. XM$4ZZ`X!83R\LAV@O"DZZV4)03RELAVB';$ZZ`W0@;(=>((!.N@.((&R'7B%`T
  1192. XM``9G%DAX`^U(>@`L3KH#9%!/(&R'7B%```PO+(=L/RR'<$ZZV0A<3T)G3KH!#
  1193. XMQ%1/)%].74YU*@!(YW``-`'$P"8!2$/&P$A#0D/4@TA`P,%(0$)`T(),WP`.7
  1194. XM3G5(YT@`0H1*@&H$1(!21$J!:@9$@0I$``%A/DI$9P)$@$S?`!)*@$YU2.=(\
  1195. XM`$*$2H!J!$2`4D1*@6H"1(%A&B`!8-@O`6$2(`$B'TJ`3G4O`6$&(A]*@$YU?
  1196. XM2.<P`$A!2D%F($A!-@$T`$)`2$"`PR(`2$`R`H+#,`%"04A!3-\`#$YU2$$F#
  1197. XM`2(`0D%(04A`0D!T#]"`TX&V@6($DH-20%'*__),WP`,3G4@;P`$(`A*&&;\I
  1198. XMD<`@"%.`3G5.50``2.<,(#@M``A.N@!P,`3!_``&)$#5[(=>2D1M"KALARYL]
  1199. XM!$J29A`Y?``"AW)P_TS?!#!.74YU,"H`!,!\``-F"CE\``6'<G#_8.1P`#`M"
  1200. XM``XO`"\M``HO$DZZ`A1/[P`,*@"PO/____]F#$ZZ`>0Y0(=R</]@N"`%8+1.]
  1201. XM5?_\2'@0`$*G3KH"C%!/*T#__`@```QG$DILAV9F""`M__Q.74YU3KH`!G``V
  1202. XM8/1.50``2'@`!$AZ`!Y.N@&N+P!.N@&P3^\`##\\``%.N@`,5$].74YU7D,*0
  1203. XM`$Y5``!*K(>,9P8@;(>,3I`_+0`(3KH`"%1/3EU.=4Y5__PO!#`M``A(P"M`4
  1204.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KP@;P`$+&R`"D[N_\H@;P`$+&R`"D[NV
  1220. XM_[@@;P`$+&R`"D[N_K8@;P`$("\`""QL@`I.[O]P(&\`!"QL@`I.[O\T3.\#U
  1221. XM```$+&R`"D[N_Q!,[P,```0L;(`*3N[^^````^P````!`````0``)_``````/
  1222. XM```#\@```^H```',````!``(`````````````````````````#(`"@%4`);_A
  1223. XM_P``$R@``!0/```````````````0````````````9``R`H``R``!,"XP,```,
  1224. XM```````````````````P+C`P`````````````````````````$@```?&````3
  1225. XM%````````````````````````````````````%P```?&````%```````````1
  1226. XM`````````````````````````.0`<0`9`&@`"`````$0!```````````````S
  1227. XM``````````!P`((````````!$`!Q`"H`:``(`````1`$````````````````C
  1228. XM`````````)0`@@````````$\`#$`/0`8``T````'$`$`````````````````^
  1229. XM``````````"!````````````?``]`#@`#0````<0`0``````````````````7
  1230. XM`````````(```````P`!``!6``D`````````(@```7P!``$```D`&0``````F
  1231. XM```J```!D`$``0``"0`J`````````#<```&D`@`!```U`$``````````1```(
  1232. XM`;@#``$``(``0`````````!'```````!`%,`Y`!3`.0```````````!3`'P`"
  1233. XM2@"T`$H`M``\`'L`/`![`$H`,0!*`$D`2@!)`#P`,``\`#``2@!O`#,`VP`S=
  1234. XM`-L`*`!N`"@`;@`S`-D`,0#9`"H`V@`J`-H`,@!O`#(`;P`J`'``*@!P`#$`,
  1235. XM;P`I`-H`*0!O`"(`VP`B`-L`%P!N`!<`;@`B`-D`(`#9`!D`V@`9`-H`(0!OX
  1236. XM`"$`;P`9`'``&0!P`"``;P`8`-H`&`!6`!$`C0`1``````$```4```',```"5
  1237. XMF``````!```%```!X````J@``````0``!0```?0```*X``````$```4```((N
  1238. XM```"R``````"```(```"'````M@``````@```@```CP```+H``````$```4`^
  1239. XM``)$```"^``````"```(```"6````P@``````@```@```G@```,8``````,`+
  1240. XM``(```*``````````````````.4`5`````````"X```"B````6@`````````H
  1241. XM`````````````````````````````````````````````````````````````
  1242. XM``````````````````````````````````````````````!.````````````.
  1243. XM````````8@````````.8```#H````Z@```.P````;`````````",````DP``)
  1244. XM`)D```";```````````````````#P````````````````````*0```"U````0
  1245. XMQ@```-<```#H````^0```0H````````!'````2<````````!-````4$```%,2
  1246. XM```!8P```7<```&1`````````_0````````$%```````````````````````]
  1247. XM`````````````````````````````:(```&L```!MP```<4```'.```!V@``X
  1248. XM`>,```'N````````````````````````````````````````````````````3
  1249. XM``````````````````````````````````````````'^```"!@```@X`````7
  1250. XM```#R````]P```0@```$/```!&P```20```$T```!.``````````````````*
  1251. XM````@```P0```````````````,S,S3X`````F9F:/P```````````````(``O
  1252. XM`$$`````@```/P```````````````.9F9L``````]<*//0````"9F9J_`````
  1253. XM````````````Q_3<OP````"6-]_```````(``````@`!````````````````'
  1254. XM`P````````$````````09@````````````````````H``0``````````````%
  1255. XM````````````````````````4@`````````````````````````````````!3
  1256. XM``(``@````````````````````4`````````T```````````````````````9
  1257. XM````,#$R,S0U-C<X.6%B8V1E9@``04)#1$5&86)C9&5F.3@W-C4T,S(Q,``*C
  1258. XM"PP-#@\*"PP-#@\)"`<&!00#`@$``*```$2```!!@```0,S,S3RCUPHY@Q)N_
  1259. XM-M&W%C*GQ:LOAC>\+-:_DRBKS'8EB7!>(MOF_1ZOZ_X;C+S+&.$N$A2T)-L1_
  1260. XMD!U\#@`!AJ$`("`@("`@("`@,#`P,#`@("`@("`@("`@("`@("`@(""00$!`_
  1261. XM0$!`0$!`0$!`0$!`#`P,#`P,#`P,#$!`0$!`0$`)"0D)"0D!`0$!`0$!`0$!X
  1262. XM`0$!`0$!`0$!`4!`0$!`0`H*"@H*"@("`@("`@("`@("`@("`@("`@("0$!`N
  1263. XM0"```!0``````^P````Y`````0```'````!T````E````)@```"X````V@``_
  1264. XM`.0```$&```!$````7````%X```!A````8P```&8```!H````:P```&T```!5
  1265. XMP````I````*4```"H````J0```*P```"M````L````+$```"T````M0```+@J
  1266. XM```"Y````O````+T```#`````P0```,0```#%````R````,X```#/````T``B
  1267. XM``.P```#M````[@```.\```#Y```!#P```1$```$X```!.0```3H```$[```[
  1268. XM!/````3T```$^```!/P```6(```%G````"D``````````````#(```%T```!G
  1269. XMB````9P```&P```!Q````Y@```.H```#P````\@```/,```#T````]0```/T?
  1270. XM```#^````_P```0````$!```!`@```0,```$%```!!@```0@```$)```!"@`.
  1271. XM``0L```$,```!#0```1L```$<```!'0```1X```$?```!(````2$```$B```,
  1272. XB!-````34```$V```!:`````````#\@```^L````!```#\H``&
  1273. X``
  1274. Xend
  1275. Xsize 14164
  1276. SHAR_EOF
  1277. echo "extracting Makefile.qmenu"
  1278. sed 's/^X//' << \SHAR_EOF > Makefile.qmenu
  1279. X# Quickmenu Module and test program (mtst).
  1280. X# Manx 3.6 Makefile.
  1281. X
  1282. Xmtst : mtst.o qmenu.o
  1283. X    ln mtst.o qmenu.o -lc -o $@
  1284. X
  1285. Xqmenu.o : qmenu.c qmenu.h
  1286. X    cc qmenu.c -o $@
  1287. X
  1288. Xmtst.o : mtst.c qmenu.h
  1289. X    cc mtst.c -o $@
  1290. SHAR_EOF
  1291. echo "extracting Readme.qmenu"
  1292. sed 's/^X//' << \SHAR_EOF > Readme.qmenu
  1293. XIntuiTools: qmenu
  1294. X
  1295. XHere's a little quick menu creation code I put together for making menus
  1296. Xfor Modeler 3D.  The instructions are in the comments.  Included are the
  1297. Xmain code itself in a module and an example program.  The code compiles
  1298. Xunder Manx 3.6, but I can't see why I wouldn't compile equally well 
  1299. Xelsewhere.
  1300. X
  1301. XEnjoy,
  1302. X
  1303. X    Stuart Ferguson        1/89
  1304. X    (shf@well.UUCP)
  1305. X
  1306. X    123 James Ave.
  1307. X    Redwood City, Ca.
  1308. X        94062
  1309. SHAR_EOF
  1310. echo "extracting mtst.c"
  1311. sed 's/^X//' << \SHAR_EOF > mtst.c
  1312. X/*
  1313. X * Example program for using quick menu package.  Contains the necessary
  1314. X * declarations for a simple menu strip which it creates and destroys after
  1315. X * letting the user play with it.
  1316. X */
  1317. X#include <intuition/intuition.h>
  1318. X#include "qmenu.h"
  1319. X
  1320. X
  1321. X#define NILSUB    {NULL,NULL}
  1322. X
  1323. X/*
  1324. X * String arrays get defined in sort-of reverse order.
  1325. X * I.e. the subitems get defined before the parent items.
  1326. X * (One rule is that menu items that cause a Requester to
  1327. X * appear are followed by "...".)
  1328. X * The string arrays themselves are terminated by a null 
  1329. X * string pointer.
  1330. X */
  1331. Xchar *mpo_str[] = {
  1332. X    "!=ORaw Text...",
  1333. X    "Processed Text...",
  1334. X    "Drawing...",
  1335. X    "Picture...",
  1336. X    "Old Settings...",
  1337. X    NULL };
  1338. X
  1339. Xchar *mps_str[] = {
  1340. X    "!=TText...",
  1341. X    "!=DDrawing...",
  1342. X    "Picture...",
  1343. X    NULL };
  1344. X
  1345. Xchar *mp_str[] = {
  1346. X    "!=NNew...",
  1347. X    "Open",
  1348. X    "!=SSave...",
  1349. X    "Save as",
  1350. X    "Print...",
  1351. X    "Save Settings",
  1352. X    "About...",
  1353. X    "-",
  1354. X    "!bQuit...",
  1355. X    NULL };
  1356. X
  1357. X/* Array of NewMenu structs to go with the above text items.
  1358. X * Needs to be a one-to-one correspondence between text items
  1359. X * (not rules) and NewMenu structs.
  1360. X */
  1361. Xstruct NewMenu mp_sub[] = {
  1362. X    NILSUB,
  1363. X    { mpo_str, NULL },
  1364. X    NILSUB,
  1365. X    { mps_str, NULL },
  1366. X    NILSUB,
  1367. X    NILSUB,
  1368. X    NILSUB,
  1369. X    NILSUB
  1370. X};
  1371. X
  1372. Xchar *mes_str[] = {
  1373. X    "!+!0111!=PPlain",
  1374. X    "!c!1!=BBold",
  1375. X    "!c!1!=IItalic",
  1376. X    "!c!1!=UUnderline",
  1377. X    NULL };
  1378. X
  1379. Xchar *me_str[] = {
  1380. X    "!=QUndo",
  1381. X    "-",
  1382. X    "!=ZDelete",
  1383. X    "!=XCut",
  1384. X    "!=CCopy",
  1385. X    "!=VPaste",
  1386. X    "-",
  1387. X    "Set Font...",
  1388. X    "Set Style",
  1389. X    NULL };
  1390. X
  1391. Xstruct NewMenu me_sub[] = {
  1392. X    NILSUB,
  1393. X    NILSUB,
  1394. X    NILSUB,
  1395. X    NILSUB,
  1396. X    NILSUB,
  1397. X    NILSUB,
  1398. X    { mes_str, NULL }
  1399. X};
  1400. X
  1401. Xchar *mdz_str[] = {
  1402. X    "!=>In",
  1403. X    "!=<Out",
  1404. X    "!=MManual",
  1405. X    NULL };
  1406. X
  1407. Xchar *mdv_str[] = {
  1408. X    "!+!tText",
  1409. X    "!+!tLines",
  1410. X    "!+!tImages",
  1411. X    "!+!tBoxes",
  1412. X    "!+!tLabels",
  1413. X    NULL };
  1414. X
  1415. Xchar *mds_str[] = {
  1416. X    "Interlace",
  1417. X    "Non-interlace",
  1418. X    "Workbench",
  1419. X    NULL };
  1420. X
  1421. Xchar *md_str[] = { 
  1422. X    "Zoom",
  1423. X    "!=AAuto Scale",
  1424. X    "-",
  1425. X    "!c!tCoordinates",
  1426. X    "Visible",
  1427. X    "-",
  1428. X    "Screen Colors...",
  1429. X    "Screen Type",
  1430. X    NULL };
  1431. X
  1432. Xstruct NewMenu md_sub[] = {
  1433. X    { mdz_str, NULL },
  1434. X    NILSUB,
  1435. X    NILSUB,
  1436. X    { mdv_str, NULL },
  1437. X    NILSUB,
  1438. X    { mds_str, NULL }
  1439. X};
  1440. X
  1441. Xchar *mhc_str[] = {
  1442. X    "Plot...",
  1443. X    "Set...",
  1444. X    "Lay in...",
  1445. X    NULL };
  1446. X
  1447. Xchar *mhw_str[] = {
  1448. X    "!+!0111111Full Impulse",
  1449. X    "!c!1011111!=1Warp 1",
  1450. X    "!c!1101111!=2Warp 2",
  1451. X    "!c!1110111!=3Warp 3",
  1452. X    "!c!1111011!=4Warp 4",
  1453. X    "!c!1111101!=5Warp 5",
  1454. X    "!c!1111110Space Normal",
  1455. X    NULL };
  1456. X
  1457. Xchar *mhp_str[] = {
  1458. X    "Stun",
  1459. X    "Kill",
  1460. X    "Maim",
  1461. X    "Burn",
  1462. X    "Overload",
  1463. X    "Ineffective",
  1464. X    "Burn Out",
  1465. X    NULL };
  1466. X
  1467. Xchar *mh_str[] = {
  1468. X    "New Course",
  1469. X    "Speed",
  1470. X    "Standard Orbit",
  1471. X    "Tractor Beam...",
  1472. X    "Lock Phasers",
  1473. X    "-",
  1474. X    "\"Make It So.\"",
  1475. X    NULL };
  1476. X
  1477. Xstruct NewMenu mh_sub[] = {
  1478. X    { mhc_str, NULL },
  1479. X    { mhw_str, NULL },
  1480. X    NILSUB,
  1481. X    NILSUB,
  1482. X    { mhp_str, NULL },
  1483. X    NILSUB
  1484. X};
  1485. X
  1486. Xchar *mt_str[] = {
  1487. X    "Hammer",
  1488. X    "Screwdriver",
  1489. X    "Chisel",
  1490. X    "Knife",
  1491. X    "Felt Pen",
  1492. X    "Air Freshener",
  1493. X    "-",
  1494. X    "Hammer Size...",
  1495. X    "Screw Type...",
  1496. X    "Pine Scent...",
  1497. X    NULL };
  1498. X
  1499. Xchar *mm_str[] = {
  1500. X    "Rotate...",
  1501. X    "Spin...",
  1502. X    "Turn Around...",
  1503. X    "Flip Out...",
  1504. X    "Randomize...",
  1505. X    "Energize...",
  1506. X    "Simplify",
  1507. X    "Complexify",
  1508. X    NULL };
  1509. X
  1510. Xchar *main_str[] = {
  1511. X    "Project",
  1512. X    "Edit",
  1513. X    "Display",
  1514. X    "Tools",
  1515. X    "Helm",
  1516. X    "Modify",
  1517. X    NULL };
  1518. X
  1519. Xstruct NewMenu main_sub[] = {
  1520. X    { mp_str, mp_sub },
  1521. X    { me_str, me_sub },
  1522. X    { md_str, md_sub },
  1523. X    { mt_str, NULL },
  1524. X    { mh_str, mh_sub },
  1525. X    { mm_str, NULL }
  1526. X};
  1527. X
  1528. Xstruct NewMenu main_menu = { main_str, main_sub };
  1529. X
  1530. Xstruct TextAttr ta = { (UBYTE*) "topaz.font", 8,0,0 };
  1531. X
  1532. X
  1533. X/* Basic stuff for the test program.
  1534. X */
  1535. Xstruct NewWindow nwin = {
  1536. X    50,20, 200,100, -1,-1, CLOSEWINDOW,
  1537. X    WINDOWCLOSE|WINDOWDRAG|ACTIVATE,
  1538. X    NULL,NULL, (UBYTE*) "Test the Menus", NULL,NULL,
  1539. X    0,0,0,0, WBENCHSCREEN
  1540. X};
  1541. X
  1542. X#define OLIB(var,nam)    (var=OpenLibrary(nam,33L))
  1543. X
  1544. Xstruct IntuitionBase *IntuitionBase;
  1545. Xstruct Window *mywin;
  1546. X
  1547. X
  1548. Xstruct Window *OpenWindow();
  1549. Xvoid *OpenLibrary();
  1550. Xvoid *GetMsg();
  1551. X
  1552. X
  1553. Xmain ()
  1554. X{
  1555. X    if (OLIB(IntuitionBase,"intuition.library")) {
  1556. X        if (mywin = OpenWindow (&nwin)) {
  1557. X            Body ();
  1558. X            CloseWindow (mywin);
  1559. X        }
  1560. X        CloseLibrary (IntuitionBase);
  1561. X    }
  1562. X}
  1563. X
  1564. X
  1565. XBody ()
  1566. X{
  1567. X    struct IntuiMessage *im;
  1568. X    struct Menu *m;
  1569. X
  1570. X    if (!(m = GenMenu (&main_menu))) return;
  1571. X
  1572. X    SetMenuStrip (mywin, m);
  1573. X
  1574. X    /* Wait for the close window message.
  1575. X     */
  1576. X    while (!(im = (struct IntuiMessage *) GetMsg (mywin->UserPort)))
  1577. X        WaitPort (mywin->UserPort);
  1578. X    ReplyMsg (im);
  1579. X
  1580. X    ReadMenuState (m);
  1581. X    ClearMenuStrip (mywin);
  1582. X    FreeMenu (m);
  1583. X}
  1584. X
  1585. X
  1586. XReadMenuState (m)
  1587. X    struct Menu *m;
  1588. X{
  1589. X    struct MenuItem    *mi;
  1590. X
  1591. X    /* Get the text style menu array and test for checkmarks.
  1592. X     */
  1593. X    mi = m[1].FirstItem[8].SubItem;
  1594. X    printf ("Text Style: ");
  1595. X    if (mi[0].Flags & CHECKED) printf ("Plain");
  1596. X    if (mi[1].Flags & CHECKED) printf ("Bold ");
  1597. X    if (mi[2].Flags & CHECKED) printf ("Italic ");
  1598. X    if (mi[3].Flags & CHECKED) printf ("Underline");
  1599. X    printf ("\n");
  1600. X}
  1601. SHAR_EOF
  1602. echo "extracting qmenu.c"
  1603. sed 's/^X//' << \SHAR_EOF > qmenu.c
  1604. X/*
  1605. X * Quick Menu Package -- An easy way to make simple (but nice) menus.
  1606. X *
  1607. X * The client programmer will generally use the GenMenu()/FreeMenu() 
  1608. X * interface which creates and frees a whole menu strip.  A menu strip
  1609. X * -- both the main strip and menu item strips -- is defined by a
  1610. X * NewMenu struct.  Each NewMenu struct (defined in qmenu.h) is just a
  1611. X * pointer to an array of strings and a pointer to an array of
  1612. X * NewMenu's.  The elements of the array of NewMenu's are paired with the
  1613. X * strings in the array and represent the sub menus for that string.
  1614. X * The string array is terminated with a null pointer.
  1615. X *
  1616. X * The package tries to do nice things, like automatically formatting
  1617. X * the menu strings into blocks with their command keys, and placing
  1618. X * markers pointing to subitem stips.  The strings for the menu items
  1619. X * can contain special control codes to control the optional 
  1620. X * characteristics of items.  Special codes come at the front of item
  1621. X * strings and are delimited with a special character (SPECIAL,
  1622. X * defined as '!' by default) and are listed briefly below:
  1623. X *
  1624. X *    c    Checkmark item
  1625. X *    t    Checkmark toggle
  1626. X *    +    Checkmark checked
  1627. X *    b    Highlight box
  1628. X *    n    Highlight none
  1629. X *    d    Disabled
  1630. X *    =C    Set command key to "C"
  1631. X *    0101...    Set item exclude mask
  1632. X *
  1633. X * Any number of 1's and 0's after the special character will set the
  1634. X * Mutual exclude bits for that item in the order they occur.  So the
  1635. X * first 1 or 0 will set bit 0 of the exclude mask, the second will
  1636. X * set bit 1, etc.  Any unset will be 0.
  1637. X *
  1638. X * Additionally, if the item string is "-", the item will be 
  1639. X * a non-selectable horizontal line (a "rule") that can be used to 
  1640. X * visually group similar items in the menu strip.  There only need
  1641. X * to be NewMenu structs in the array for text menu items, not rules,
  1642. X * but don't forget to account for rules when counting MenuItem's
  1643. X * since they take a slot.
  1644. X *
  1645. X *
  1646. X * GenMenu() takes a pointer to a NewMenu struct and will create a main
  1647. X * Menu strip from the strings in the struct, with menu items from the
  1648. X * associated NewMenu's.  It returns a pointer to a Menu struct which is
  1649. X * the first element in the list for this strip.
  1650. X *
  1651. X * GenStrip() takes a pointer to an array of strings and creates a
  1652. X * top-level set of Menu structs for the main menu strip.
  1653. X *
  1654. X * FreeMenu() frees a Menu strip created with either GenMenu() or
  1655. X * GenStrip().
  1656. X *
  1657. X * GenItems() takes a pointer to a NewMenu struct and creates a single
  1658. X * list of MenuItem's from the description.  It also takes an X and Y
  1659. X * offset for all the elements in the list.
  1660. X *
  1661. X * FreeMItem() frees structures created by the above function.
  1662. X *
  1663. X * AttachSubMenu() takes a single MenuItem and a NewMenu struct and
  1664. X * attaches the MenuItems created from that NewMenu struct to the
  1665. X * parent MenuItem.  The parent should also have been created with
  1666. X * GenItems() in order to work correctly.  AttachSubMenu() places a
  1667. X * little maker on the parent item to show that it has subitems.  It
  1668. X * returns 1 for sucess and 0 for failure.
  1669. X *
  1670. X * -- WARNING:
  1671. X *
  1672. X * The client programmer is completely responsible for keeping the
  1673. X * menus within the bounds of the screen and for keeping within the
  1674. X * limits of Intuition.  The menu structures will not adjust as they
  1675. X * hit the borders of the screen (which might be a nice enhancement).
  1676. X * The strings in the NewMenu structures cannot be changed or deleted
  1677. X * while the Menus are in use, although they can be used to create
  1678. X * multiple Menus from the same strings.
  1679. X *
  1680. X **
  1681. X * This code can be used and modified freely.  Do let me know of any
  1682. X * improvements or enhancements you may add, and be sure to give credit
  1683. X * where credit is due (in the comments) if you redistribute this code.
  1684. X *
  1685. X *    Stuart Ferguson        1/89
  1686. X *    (shf@well.UUCP)
  1687. X */
  1688. X#include <intuition/intuition.h>
  1689. X#include "qmenu.h"
  1690. X
  1691. X/*
  1692. X * Some useful macros for allocating and freeing structures and
  1693. X * arrays of structures.
  1694. X */
  1695. X#define NEW(typ)    (typ*)AllocMem((long)sizeof(typ),0L)
  1696. X#define FREI(p)        FreeMem(p,(long)sizeof(*p))
  1697. X
  1698. X#define NEW_N(typ,n)    (typ*)AllocMem((long)((n)*sizeof(typ)),0L)
  1699. X#define FREI_N(p,n)    FreeMem(p,(long)((n)*sizeof(*p)))
  1700. X
  1701. Xchar * AllocMem();
  1702. X
  1703. X/*
  1704. X * Definitions for formatting the menus.  Glossary:
  1705. X *
  1706. X *    TEXTCOLOR    - color of the text items in the menus.
  1707. X *    MARKCOLOR    - color of the subitem marker.
  1708. X *    RULECOLOR    - color of the horizontal lines in the menus.
  1709. X *    RULEHEIGHT    - vertical thickness of the horizontal rules.
  1710. X *    RULEGAP        - vertical blank space around the rules.
  1711. X *    RULEMARGIN    - horizontal blank space around the rules.
  1712. X *    TEXTGAP        - vertical blank space around the text items.
  1713. X *    TEXTMARGIN    - horizontal blank space around the text items.
  1714. X *    MAINWID        - width of the text font on the main menu.
  1715. X *    MAINGAP        - spacing between items on the main menu strip.
  1716. X *    SUBINDENT    - overlap between items and their subitems.
  1717. X *    SUBDOWN        - vertical shift between items and their subitems.
  1718. X */
  1719. X#define TEXTCOLOR    2
  1720. X#define MARKCOLOR    3
  1721. X#define RULECOLOR    0
  1722. X#define RULEHEIGHT    2
  1723. X#define RULEGAP        4
  1724. X#define RULEMARGIN    10
  1725. X#define TEXTGAP        2
  1726. X#define TEXTMARGIN    4
  1727. X#define MAINWID        10
  1728. X#define MAINGAP        10
  1729. X#define SUBINDENT    18
  1730. X#define SUBDOWN        0
  1731. X
  1732. X/*
  1733. X * Escape character for special control codes in text items strings.
  1734. X */
  1735. X#define SPECIAL        '!'
  1736. X
  1737. X/*
  1738. X * The extern "ta" is set by the client program for
  1739. X * the font to use for these menus.
  1740. X */
  1741. Xextern struct TextAttr ta;
  1742. X
  1743. X/*
  1744. X * Generic templates to use for creating the dynamic menu structures. 
  1745. X */
  1746. Xstatic struct IntuiText
  1747. X  generic_itext = {TEXTCOLOR, 0, JAM1, TEXTMARGIN/2, TEXTGAP/2, &ta,NULL,NULL},
  1748. X  /*
  1749. X  generic_smark = {MARKCOLOR, 0, JAM1, 0, TEXTGAP/2, &ta, (UBYTE *) ";", NULL};
  1750. X  */
  1751. X  generic_smark = {MARKCOLOR, 0, JAM1, 0, TEXTGAP/2, &ta, (UBYTE *) ">>", NULL};
  1752. X
  1753. Xstatic struct Menu
  1754. X  generic_main = {NULL, 0, 0, 0, 10, MENUENABLED, NULL, NULL};
  1755. X
  1756. Xstatic struct MenuItem
  1757. X  generic_mitem = {
  1758. X     NULL, 0, 0, 0, 0,
  1759. X     ITEMTEXT | ITEMENABLED | HIGHCOMP,
  1760. X     0, NULL, NULL, 0, NULL, 0
  1761. X};
  1762. X
  1763. X/* Image struct with no imagery for the horizontal lines.
  1764. X */
  1765. Xstatic struct Image
  1766. X  generic_hrule = {0, 0, 1, RULEHEIGHT, 2, NULL, 0, RULECOLOR, NULL};
  1767. X
  1768. Xstatic struct MenuItem
  1769. X  generic_hitem = {
  1770. X     NULL, RULEMARGIN/2, 0, 0, 0,
  1771. X     ITEMENABLED | HIGHNONE,
  1772. X     0, NULL, NULL, 0, NULL, 0
  1773. X};
  1774. X
  1775. X
  1776. X/*
  1777. X * Takes an array of strings and associated array of NewMenu structs
  1778. X * (as a single NewMenu struct) and constructs a menu strip from the
  1779. X * descripton.  This is the main high-level call that most clients
  1780. X * will make.
  1781. X */
  1782. Xstruct Menu * GenMenu (nmen)
  1783. X    register struct NewMenu *nmen;
  1784. X{
  1785. X    register short  i, ok, n;
  1786. X    register struct Menu *mm;
  1787. X    register struct MenuItem *mi;
  1788. X
  1789. X    /* Count menus to be generated and create top level structure.
  1790. X     */
  1791. X    for (n = 0; nmen->str[n]; n++) ;
  1792. X    mm = GenStrip (nmen->str);
  1793. X    if (!mm) return NULL;
  1794. X
  1795. X    /* Create the item strip for each main menu and attach to the
  1796. X     * top level Menu structure.  Any failure causes the whole
  1797. X     * thing to crumble to dust.
  1798. X     */
  1799. X    ok = 1;
  1800. X    nmen = nmen->submenu;
  1801. X    for (i = 0; i < n; i++) {
  1802. X        if (nmen->str) {
  1803. X            mi = GenItems (nmen, 0L, 0L);
  1804. X            mm[i].FirstItem = mi;
  1805. X            ok &= (mi != NULL);
  1806. X        }
  1807. X        nmen ++;
  1808. X    }
  1809. X    if (!ok) {
  1810. X        FreeMenu (mm);
  1811. X        return NULL;
  1812. X    }
  1813. X    return mm;
  1814. X}
  1815. X
  1816. X
  1817. X/*
  1818. X * Generate a menu strip.  Just creates the top level Menu structures,
  1819. X * linked together and intialized.  Takes an array of pointers to
  1820. X * strings.
  1821. X */
  1822. Xstruct Menu * GenStrip (str)
  1823. X    char **str;
  1824. X{
  1825. X    register short  i, x, num;
  1826. X    register struct Menu *mm, *m;
  1827. X
  1828. X    /*
  1829. X     * Create enough struct Menu's for the menu strip. 
  1830. X     */
  1831. X    for (num = 0; str[num]; num++) ;
  1832. X    mm = NEW_N (struct Menu, num);
  1833. X    if (!mm) return NULL;
  1834. X
  1835. X    /*
  1836. X     * Init the structures using the generic Menu struct as a template.
  1837. X     * NOTE: the size of the font for these item labels is unknown for
  1838. X     *       windows on the Workbench screen, so a size should be used
  1839. X     *       that will work with 60 & 80 column fonts. 
  1840. X     */
  1841. X    x = 0;
  1842. X    for (i = 0; i < num; i++) {
  1843. X        m = &mm[i];
  1844. X        *m = generic_main;
  1845. X        m->LeftEdge = x;
  1846. X        m->Width = strlen (str[i]) * MAINWID + TEXTMARGIN;
  1847. X        x += m->Width + MAINGAP;
  1848. X        m->MenuName = str[i];
  1849. X        m->NextMenu = m + 1;
  1850. X    }
  1851. X    mm[num - 1].NextMenu = NULL;
  1852. X    return mm;
  1853. X}
  1854. X
  1855. X
  1856. X/*
  1857. X * Attach a submenu to a MenuItem.  Takes the parent MenuItem and a
  1858. X * NewMenu structure that will be attached as a sub-menu.  
  1859. X * Attaches a ";" mark at the end of the parent item and calls
  1860. X * GenItems() to create the sub-menu strip.
  1861. X */
  1862. XBOOL AttachSubMenu (mi, nmen)
  1863. X    register struct MenuItem    *mi;
  1864. X    struct NewMenu            *nmen;
  1865. X{
  1866. X    register struct IntuiText *it;
  1867. X
  1868. X    /* Create an IntuiText with the marker and position it
  1869. X     * at the right edge of the item.
  1870. X     */
  1871. X    if (!(it = NEW (struct IntuiText))) return FALSE;
  1872. X    *it = generic_smark;
  1873. X    it->LeftEdge = mi->Width - IntuiTextLength (it) - 2;
  1874. X
  1875. X    /* Create the subitem structure and attach to the main item.
  1876. X     */
  1877. X    if (!(mi->SubItem = GenItems
  1878. X          (nmen, (LONG) (mi->Width - SUBINDENT), (LONG) SUBDOWN))) {
  1879. X        FREI (it);
  1880. X        return FALSE;
  1881. X    }
  1882. X
  1883. X    /* Only if it all worked attach the new text structure.
  1884. X     */
  1885. X    ((struct IntuiText *) mi->ItemFill)->NextText = it;
  1886. X    return TRUE;
  1887. X}
  1888. X
  1889. X
  1890. X/*
  1891. X * Takes the given menu text item and skips past the special control
  1892. X * codes while adjusting the associated MenuItem appropriately.
  1893. X * Special codes are in the form of "!x", where "x" is:
  1894. X *
  1895. X *    c    Checkmark item
  1896. X *    t    Checkmark toggle
  1897. X *    b    Highlight box
  1898. X *    n    Highlight none
  1899. X *    d    Disabled
  1900. X *    +    Checkmark checked
  1901. X *    =C    Set command key to "C"
  1902. X *    1010...    Set item exclude mask
  1903. X *
  1904. X * Takes the mostly defined MenuItem and diddles it.  Returns a pointer
  1905. X * to the item text with control codes stripped.
  1906. X */
  1907. Xstatic UBYTE * ProcessSpecialStuff (str, mi)
  1908. X    char *str;
  1909. X    struct MenuItem *mi;
  1910. X{
  1911. X    register LONG    x;
  1912. X    register int    i;
  1913. X
  1914. X    while (*str == SPECIAL) {
  1915. X        switch (*++str) {
  1916. X            case 'c':
  1917. X            mi->Flags |= CHECKIT;
  1918. X            break;
  1919. X            case 't':
  1920. X            mi->Flags |= CHECKIT | MENUTOGGLE;
  1921. X            break;
  1922. X            case 'b':
  1923. X            mi->Flags &= ~HIGHFLAGS;
  1924. X            mi->Flags |= HIGHBOX;
  1925. X            break;
  1926. X            case 'n':
  1927. X            mi->Flags &= ~HIGHFLAGS;
  1928. X            mi->Flags |= HIGHNONE;
  1929. X            break;
  1930. X            case 'd':
  1931. X            mi->Flags &= ~ITEMENABLED;
  1932. X            break;
  1933. X            case '+':
  1934. X            mi->Flags |= CHECKIT | CHECKED;
  1935. X            break;
  1936. X            case '=':
  1937. X            mi->Flags |= COMMSEQ;
  1938. X            mi->Command = *++str;
  1939. X            break;
  1940. X            case '0':
  1941. X            case '1':
  1942. X            x = 0;
  1943. X            i = 0;
  1944. X            while (*str == '0' || *str == '1')
  1945. X                x += (*str++ - '0') << (i++);
  1946. X            mi->MutualExclude = x;
  1947. X            str--;
  1948. X            break;
  1949. X        }
  1950. X        str++;
  1951. X    }
  1952. X    return (UBYTE*) str;
  1953. X}
  1954. X
  1955. X
  1956. X/*
  1957. X * Construct a basic item list for a menu.  Takes a NewMenu structure
  1958. X * which contains a pointer to an array of pointers to strings and a 
  1959. X * pointer to an array of NewMenu structures.  The strings contain the
  1960. X * item text for each menu plus optional special control codes.  If the
  1961. X * string is "-", the item will be a horizontal rule rather than a text
  1962. X * item.  The NewMenu structures, if not NULL, are the sub-menu's for
  1963. X * each menu in the array.
  1964. X * "x" and "y" are the horizontal and vertical offsets of this set of
  1965. X * MenuItems.  These are set by AttachSubMenu() for positioning submenus
  1966. X * under their parent items.
  1967. X */
  1968. Xstruct MenuItem *GenItems (nmen, x, y)
  1969. X    struct NewMenu *nmen;
  1970. X    LONG    x, y;
  1971. X{
  1972. X    register struct MenuItem *mi, *cmi;
  1973. X    register struct IntuiText *itext;
  1974. X    struct Image   *img;
  1975. X    register short  i, len, max;
  1976. X    short           n;
  1977. X    struct NewMenu *sub;
  1978. X
  1979. X    /* Count menu items (n) and allocate an array for the strip.
  1980. X     */
  1981. X    for (n = 0; nmen->str[n]; n++) ;
  1982. X    if (!(mi = NEW_N (struct MenuItem, n))) return NULL;
  1983. X
  1984. X    /* Counts the number of rules in the menu ("-" strings)
  1985. X     * and allocates the structures for the lines and the text items.
  1986. X     */
  1987. X    max = 0;
  1988. X    for (i = 0; i < n; i++) max += (*nmen->str[i] == '-');
  1989. X    if (n - max)
  1990. X        if (!(itext = NEW_N (struct IntuiText, n - max))) {
  1991. X            FREI_N (mi, n);
  1992. X            return NULL;
  1993. X        }
  1994. X    if (max)
  1995. X        if (!(img = NEW_N (struct Image, max))) {
  1996. X            FREI_N (mi, n);
  1997. X            if (n - max) FREI_N (itext, n - max);
  1998. X            return NULL;
  1999. X        }
  2000. X
  2001. X    /* Loop through text menu items and initialize the
  2002. X     * associated IntuiText structures.  Compute the maximum
  2003. X     * width of the menu taking command keys into account while
  2004. X     * assigning all the other parts of the text MenuItem's.
  2005. X     */
  2006. X    max = 0;
  2007. X    for (i = 0; i < n; i++) {
  2008. X        if (*nmen->str[i] == '-') continue;    /* skip rules */
  2009. X
  2010. X        /* Init the text MenuItem to point to the assocd IntuiText.
  2011. X         */
  2012. X        cmi = &mi[i];
  2013. X        *cmi = generic_mitem;
  2014. X        cmi->ItemFill = (APTR) itext;
  2015. X
  2016. X        /* Init the IntuiText and adjust the MenuItem from the
  2017. X         * flags set in the menu text string.
  2018. X         */
  2019. X        *itext = generic_itext;
  2020. X        itext->IText = ProcessSpecialStuff (nmen->str[i], cmi);
  2021. X
  2022. X        /* Make a first cut at measuring the length of the item.
  2023. X         */
  2024. X        len = IntuiTextLength (itext) + TEXTMARGIN;
  2025. X
  2026. X        /* If command key set, add to length.
  2027. X         */
  2028. X        if (cmi->Flags & COMMSEQ) len += COMMWIDTH + MAINWID;
  2029. X
  2030. X        /* If this is a checkmark item, shift the text over to
  2031. X         * make room and add that to the length.
  2032. X         * Compute the max length.
  2033. X         */
  2034. X        if (cmi->Flags & CHECKIT) {
  2035. X            itext->LeftEdge += CHECKWIDTH;
  2036. X            len += CHECKWIDTH;
  2037. X        }
  2038. X        if (len > max) max = len;
  2039. X        itext ++;
  2040. X    }
  2041. X
  2042. X    /* Secondary assignment loop.  Position the text MenuItems and
  2043. X     * init the horizontal lines.
  2044. X     */
  2045. X    for (i = 0; i < n; i++) {
  2046. X        cmi = &mi[i];
  2047. X
  2048. X        if (*nmen->str[i] != '-') {
  2049. X            cmi->LeftEdge = x;
  2050. X            cmi->TopEdge = y;
  2051. X            cmi->Width = max;
  2052. X            cmi->Height = ta.ta_YSize + TEXTGAP;
  2053. X            y += cmi->Height;
  2054. X        } else {
  2055. X
  2056. X            /* Rule items point to their Image structure
  2057. X             * and are just a little narrower than the
  2058. X             * menu itself.
  2059. X             */
  2060. X            *img = generic_hrule;
  2061. X            img->Width = max - RULEMARGIN;
  2062. X            *cmi = generic_hitem;
  2063. X            cmi->TopEdge = y + RULEGAP/2;
  2064. X            y += RULEHEIGHT + RULEGAP;
  2065. X            cmi->ItemFill = (APTR) img;
  2066. X            img ++;
  2067. X        }
  2068. X        cmi->NextItem = cmi + 1;
  2069. X    }
  2070. X    mi[n - 1].NextItem = NULL;
  2071. X
  2072. X    /* Attach submenu's, if any.
  2073. X     */
  2074. X    if (!(sub = nmen->submenu)) return mi;
  2075. X
  2076. X    /* Use "max" as a flag for the success of the attachments.
  2077. X     */
  2078. X    max = 1;
  2079. X    for (i = 0; i < n; i++) {
  2080. X        if (*nmen->str[i] == '-') continue;
  2081. X        if (sub->str)
  2082. X            max &= AttachSubMenu (&mi[i], sub);
  2083. X        sub ++;
  2084. X    }
  2085. X    if (!max) {
  2086. X        FreeMItem (mi);
  2087. X        return NULL;
  2088. X    }
  2089. X    return mi;
  2090. X}
  2091. X
  2092. X
  2093. X/*
  2094. X * Free a Menu structure created by GenStrip() that has items 
  2095. X * created with GenItems().
  2096. X */
  2097. Xvoid FreeMenu (mm)
  2098. X    struct Menu    *mm;
  2099. X{
  2100. X    register short  i;
  2101. X    register struct Menu *t;
  2102. X
  2103. X    i = 0;
  2104. X    for (t = mm; t; t = t->NextMenu) {
  2105. X        if (t->FirstItem) FreeMItem (t->FirstItem);
  2106. X        i++;
  2107. X    }
  2108. X    FREI_N (mm, i);
  2109. X}
  2110. X
  2111. X
  2112. X/*
  2113. X * Free a MenuItem structure created by GenItems().
  2114. X */
  2115. Xvoid FreeMItem (mi)
  2116. X    register struct MenuItem *mi;
  2117. X{
  2118. X    register short  nit, nimg;
  2119. X    register struct MenuItem *c;
  2120. X    register struct IntuiText *it = NULL, *it1;
  2121. X    struct Image   *img = NULL;
  2122. X
  2123. X    /* Scan the MenuItem structures and count the number of images
  2124. X     * and IntuiText structures.  Find the pointer to the first of
  2125. X     * each structure in the set.  That will be the first element
  2126. X     * in the array that was allocated as a unit.
  2127. X     */
  2128. X    nit = nimg = 0;
  2129. X    for (c = mi; c; c = c->NextItem) {
  2130. X        if (c->SubItem) FreeMItem (c->SubItem);
  2131. X        if (c->Flags & ITEMTEXT) {
  2132. X            it1 = (struct IntuiText *) c->ItemFill;
  2133. X            if (!it) it = it1;
  2134. X            nit++;
  2135. X
  2136. X            /* Free the subitem marker, if any.
  2137. X             */
  2138. X            if (it1->NextText) FREI (it1->NextText);
  2139. X        } else {
  2140. X            if (!img) img = (struct Image *) c->ItemFill;
  2141. X            nimg++;
  2142. X        }
  2143. X    }
  2144. X
  2145. X    /* Free the arrays of structures of images and texts, as
  2146. X     * well as the main array of MenuItem structures themselves.
  2147. X     */
  2148. X    if (nit) FREI_N (it, nit);
  2149. X    if (nimg) FREI_N (img, nimg);
  2150. X    FREI_N (mi, nit + nimg);
  2151. X}
  2152. SHAR_EOF
  2153. echo "extracting qmenu.h"
  2154. sed 's/^X//' << \SHAR_EOF > qmenu.h
  2155. Xstruct NewMenu {
  2156. X    char **str;
  2157. X    struct NewMenu *submenu;
  2158. X};
  2159. X
  2160. X
  2161. Xstruct Menu *GenMenu();
  2162. Xstruct Menu *GenStrip();
  2163. Xstruct MenuItem *GenItems();
  2164. XLONG AttachSubItem();
  2165. Xvoid FreeMenu();
  2166. Xvoid FreeMItem();
  2167. SHAR_EOF
  2168. echo "extracting request.h"
  2169. sed 's/^X//' << \SHAR_EOF > request.h
  2170. XUBYTE mot_nbuf[2][NUMCHR] = {
  2171. X "0.00", "0.00"
  2172. X};
  2173. X
  2174. Xstruct StringInfo mot_sinfo[] = {
  2175. X  {&mot_nbuf[0][0],undo,0,NUMCHR,0},
  2176. X  {&mot_nbuf[1][0],undo,0,NUMCHR,0}
  2177. X};
  2178. X
  2179. Xstruct Gadget mot_gad[] = {
  2180. X  {&mot_gad[1],113,25,104,8,
  2181. X   GADGHCOMP,RELVERIFY,STRGADGET|REQGADGET,
  2182. X   NULL,NULL,NULL,0,(APTR)&mot_sinfo[0],STR_ID,NULL},
  2183. X  {&mot_gad[2],113,42,104,8,
  2184. X   GADGHCOMP,RELVERIFY,STRGADGET|REQGADGET,
  2185. X   NULL,NULL,NULL,0,(APTR)&mot_sinfo[1],STR_ID,NULL},
  2186. X  {&mot_gad[3],49,61,24,13,
  2187. X   GADGHCOMP,ENDGADGET|GADGIMMEDIATE|RELVERIFY,BOOLGADGET|REQGADGET,
  2188. X   NULL,NULL,NULL,0,NULL,OK_ID,NULL},
  2189. X  {NULL,124,61,56,13,
  2190. X   GADGHCOMP,ENDGADGET|GADGIMMEDIATE|RELVERIFY,BOOLGADGET|REQGADGET,
  2191. X   NULL,NULL,NULL,0,NULL,CAN_ID,NULL}
  2192. X};
  2193. X
  2194. Xstruct IntuiText mot_txt[] = {
  2195. X  {3,0,JAM2,86,9,&ta,(UBYTE*)"C VALUE",&mot_txt[1]},
  2196. X  {1,0,JAM2,9,25,&ta,(UBYTE*)"Real Number:",&mot_txt[2]},
  2197. X  {1,0,JAM2,9,42,&ta,(UBYTE*)"Imag Number:",&mot_txt[3]},
  2198. X  {2,0,JAM2,53,64,&ta,(UBYTE*)"Ok",&mot_txt[4]},
  2199. X  {3,0,JAM2,128,64,&ta,(UBYTE*)"Cancel",NULL}
  2200. X};
  2201. X
  2202. Xshort mot_brd_XY[] = {
  2203. X  1,83, 228,83, 228,0, 0,0, 0,83, 
  2204. X  124,74, 180,74, 180,60, 123,60, 123,74, 
  2205. X  49,74, 73,74, 73,60, 48,60, 48,74, 
  2206. X  111,51, 219,51, 219,40, 110,40, 110,51, 
  2207. X  217,49, 217,42, 218,42, 218,50, 111,50, 111,42, 112,42, 112,49, 
  2208. X  111,41, 218,41, 
  2209. X  111,34, 219,34, 219,23, 110,23, 110,34, 
  2210. X  217,32, 217,25, 218,25, 218,33, 111,33, 111,25, 112,25, 112,32, 
  2211. X  111,24, 218,24, 
  2212. X  86,17, 141,17
  2213. X};
  2214. Xstruct Border mot_brd[] = {
  2215. X  {0,0,1,0,JAM1,5,&mot_brd_XY[0],&mot_brd[1]},
  2216. X  {0,0,1,0,JAM1,5,&mot_brd_XY[10],&mot_brd[2]},
  2217. X  {0,0,1,0,JAM1,5,&mot_brd_XY[20],&mot_brd[3]},
  2218. X  {0,0,1,0,JAM1,5,&mot_brd_XY[30],&mot_brd[4]},
  2219. X  {0,0,2,0,JAM1,8,&mot_brd_XY[40],&mot_brd[5]},
  2220. X  {0,0,2,0,JAM1,2,&mot_brd_XY[56],&mot_brd[6]},
  2221. X  {0,0,1,0,JAM1,5,&mot_brd_XY[60],&mot_brd[7]},
  2222. X  {0,0,2,0,JAM1,8,&mot_brd_XY[70],&mot_brd[8]},
  2223. X  {0,0,2,0,JAM1,2,&mot_brd_XY[86],&mot_brd[9]},
  2224. X  {0,0,3,0,JAM1,2,&mot_brd_XY[90],NULL}
  2225. X};
  2226. X
  2227. X
  2228. Xstruct Requester mot_req = {
  2229. X  NULL,0,0,229,84,0,0,mot_gad,mot_brd,mot_txt,0,0,
  2230. X  NULL,{NULL},NULL,NULL,{NULL}};
  2231. SHAR_EOF
  2232. echo "End of archive 1 (of 1)"
  2233. # if you want to concatenate archives, remove anything after this line
  2234. exit
  2235.